Reverse Engineering
{"author": ["ret2basic"]}
Transformation
Challenge
I wonder what this really is... enc ''.join([chr((ord(flag[i]) << 8) + ord(flag[i + 1])) for i in range(0, len(flag), 2)])
Solution
The encoding scheme acts on two characters from the flag each time. The first character is used as higher 8 bits, while the second character is used as lower 8 bits. Together, the 2-character pair is transformed into a 16-bit binary number and this binary number is converted to ASCII character.
Implementation
#!/usr/bin/env python3
with open('enc', 'r') as f:
encoded = f.read()
flag = ''
for ch in encoded:
binary = "{0:016b}".format(ord(ch))
first_half, second_half = binary[:8], binary[8:]
flag += chr(int(first_half, 2))
flag += chr(int(second_half, 2))
print(flag)keygenme-py
Challenge
Source Code
Solution
According to the global variables declared at the beginning of the source code, the flag is picoCTF{1n_7h3_|<3y_of_xxxxxxxx} where x stands for a "dynamic" character. Our objective is to reverse engineer the check_key function and pass the check.
Note that check_key is not fully implemented and there are eight if statements checking if a certain character is valid. We could simply write a script and recover each character.
Implementation
crackme-py
Challenge
Source Code
Solution
Modify the source code to call the decode_secret function.
Implementation
ARMssembly 0
Challenge
What integer does this program print with arguments 1765227561 and 1830628817? File: chall.S Flag format: picoCTF{XXXXXXXX} -> (hex, lowercase, no 0x, and 32 bits. ex. 5614267 would be picoCTF{0055aabb})
Assembly with Comments
Solution
bls: Branch on Lower than or Same.
The main function calls atoi twice to convert the arguments to integers and then calls func1 to compare those two integers. Since , the control flow goes to .L2. Now w0 = [sp+8] = 1830628817 = x0.
Eventually, when printf is called, the value stored in x0 will be printed (calling convention). Hence this program prints 1830628817, which is 0x6d1d2dd1 in hex.
speeds and feeds
Challenge
There is something on my shop network running at mercury.picoctf.net:53740, but I can't tell what it is. Can you?
Solution
Save the G-code to a file:
Use NC Viewer to plot the flag.
Shop
Challenge
Best Stuff - Cheap Stuff, Buy Buy Buy... Store Instance: source. The shop is open for business at nc mercury.picoctf.net 34938.
Solution
Buy -10 "Quiet Quiches" and then buy 1 flag. Convert ASCII numbers to text.
Implementation
ARMssembly 1
Challenge
For what argument does this program print win with variables 85, 6 and 3? File: chall_1.S Flag format: picoCTF{XXXXXXXX} -> (hex, lowercase, no 0x, and 32 bits. ex. 5614267 would be picoCTF{0055aabb})
Assembly with Comments
Solution
Note that the x29 register is the frame pointer in ARM64. It is equivalent to the RBP register in Intel x86-64. The function func is just doing math:
Hence arg = 1813, which is 0x715 in hex.
ARMssembly 2
Challenge
What integer does this program print with argument 3848786505? File: chall_2.S Flag format: picoCTF{XXXXXXXX} -> (hex, lowercase, no 0x, and 32 bits. ex. 5614267 would be picoCTF{0055aabb})
Solution
Note that the wzr register is equivalent to 0. The instruction str wzr, [sp, 24] zeros out the content of [sp+24].
Here [sp+24] is the result and [sp+28] is the counter. The loop keeps increment [sp+24] by 3 and compares the counter [sp+28] with 3848786505. In the end, the result [sp+24] is printed out. In other word, the program computes 3848786505 * 3 = 11546359515, which is 0x2b03776db in hex. Since the flag requires 32-bit hex, this hex number is truncated as 0xb03776db.
Hurry up! Wait!
Challenge
Solution
Each function call prints out a character:

gogo
Challenge
Hmmm this is a weird file... enter_password. There is a instance of the service running at mercury.picoctf.net:35862.
Solution
ARMssembly 3
Challenge
What integer does this program print with argument 3350728462? File: chall_3.S Flag format: picoCTF{XXXXXXXX} -> (hex, lowercase, no 0x, and 32 bits. ex. 5614267 would be picoCTF{0055aabb})
Assembly with Comments
Solution
The program computes and w0, w0, 1, where w0 is the argument. If the w0 & 1 = 1, it increments the counter by 3. Otherwise, it does nothing and continues. After each round of testing, the program divides w0 by 2 and repeats this test until w0 = 0.
Implementation
Let's get dynamic
Challenge
Can you tell what this file is reading? chall.S
Solution
Compile the assembly code:
Disassemble the main function:

Since PIE is enabled, all the addresses here are just offsets. We need to run the program for the correct addresses to load:

The memcmp function compares our input with the flag. Set a breakpoint on memcmp and run the program again:
The flag is located in RSI at this moment:

Easy as GDB
Challenge
The flag has got to be checked somewhere... File: brute
Solution
Take a look at the pseudocode:

Here unk_2008 is the encrypted flag:

This is a nice use case for the angr template. What we have to do here is:
Figure out the flag length
Find the address of the "Correct!" state
Find the address of the "Incorrect." state
The length of the encrypted flag is 30, so the flag in clear should be 30-byte long as well.
The call puts instruction for "Correct!":

The call puts instruction for "Incorrect.":

Implementation
Start an angr Docker environment:
Run this script and wait. The script will take some time to finish, so be patient.
ARMssembly 4
Challenge
What integer does this program print with argument 3964545182? File: chall_4.S Flag format: picoCTF{XXXXXXXX} -> (hex, lowercase, no 0x, and 32 bits. ex. 5614267 would be picoCTF{0055aabb})
Assembly with Comments
Solution
Here is my note:
Powershelly
Someone, pls solve it!
Challenge
It's not a bad idea to learn to read Powershell. We give you the output, but do you think you can find the input? rev_PS.ps1 output.txt
Solution
Todo!
Rolling My Own
Someone, pls solve it!
Challenge
I don't trust password checkers made by other people, so I wrote my own. It doesn't even need to store the password! If you can crack it I'll give you a flag. remote nc mercury.picoctf.net 17615
Solution
Todo!
Checkpass
Someone, pls solve it!
Challenge
What is the password? File: checkpass Flag format: picoCTF{...}
Solution
Todo!
Last updated