Skip to content

Commit 2f4ba9a

Browse files
author
YASME-Tim
committed
Merge branch 'master' of https://github.com/ctfs/write-ups-2015
2 parents cccb26b + 52f45d6 commit 2f4ba9a

File tree

8 files changed

+179
-58
lines changed

8 files changed

+179
-58
lines changed

cyber-security-challenge-2015/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@
3636
* [NSA](web-application-security/nsa)
3737
* [Security Terminology v2](general-security-knowledge/security-terminology-v2)
3838
* [Espionage](digital-forensics/espionage)
39+
* [Data Extraction](digital-forensics/data-extraction)
3940

4041
## External write-ups only
4142

4243
* none yet
4344

4445
## Missing write-ups
4546

46-
* [Data Extraction](digital-forensics/data-extraction)
4747
* [0day Hunting](web-application-security/0day-hunting)
4848
* [NVISO File Host](web-application-security/nviso-file-host)

cyber-security-challenge-2015/digital-forensics/data-extraction/README.md

+103-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,109 @@
88
99
## Write-up
1010

11-
(TODO)
11+
For once, it payed off if you were paying attention in your highschool biology classes. When you learned about the birds and the bees, you also learned about DNA and RNA. That's exactly what this is.
12+
13+
![DNA](images/dnarna.gif)
14+
( Taken from http://www.sophia.org/tutorials/video-material-10-dna-rna )
15+
16+
So let's convert the image to the corresponding DNA (or RNA) characters:
17+
18+
```python
19+
from PIL import Image
20+
21+
im = Image.open("output2.jpg")
22+
print im.format, im.size, im.mode
23+
24+
width = im.size[0]
25+
height = im.size[1]
26+
27+
startX = 9
28+
startY = 14
29+
30+
spacingX = 19
31+
spacingY = 28
32+
33+
""""
34+
# blue = 224 = C
35+
# red = 228 = T
36+
# yellow = 103 = G
37+
# green = 2 = A
38+
"""
39+
40+
# T
41+
def blue(r, g, b):
42+
return abs(r-5) < 15 and abs(g-161) < 15 and abs(b-225) < 15
43+
44+
# T
45+
def red(r, g, b):
46+
return abs(r-237) < 15 and abs(g-28) < 15 and abs(b-34) < 15
47+
48+
# A
49+
def green(r, g, b):
50+
return abs(r-35) < 15 and abs(g-178) < 15 and abs(b-73) < 15
51+
# C
52+
def yellow(r, g, b):
53+
return abs(r-254) < 15 and abs(g-240) < 15 and abs(b-11) < 15
54+
55+
sol = ""
56+
y = startY
57+
while y < height:
58+
x = startX
59+
while x < width:
60+
r, g, b = im.getpixel((x, y))
61+
print r, g, b
62+
63+
if blue(r, g, b):
64+
sol += "C"
65+
if red(r, g, b):
66+
sol += "U"
67+
if green(r, g, b):
68+
sol += "A"
69+
if yellow(r, g, b):
70+
sol += "G"
71+
72+
73+
x += spacingX
74+
y += spacingY
75+
76+
print sol
77+
```
78+
Which gives us:
79+
```
80+
GACAUUUAAUGGGGUCAAUCUAUGUUCUCGGGAAUAGAAGAGCACUUCAGCGGGACUCUUUUAGACCCACGAGUAGCCGGCAAGCAGCUAGAUAAGCUAGUAGAUGGAGACCGCACCGCACUAUAGCAUAUGCUAGCUUAUAGGUCACACCUAUGAGGCAAGGAGCUAGUAGUAUAUCACCUCACUUCGCUGGGGGUGGUUUUAGUAUUGCCAUUUCCCAUACCGUAUGUGAAGACGUCGAGACAUUCCAUGGGCGUUUUAAGGCGCGGCGUUCUCUCCGCCCUGGUUCACGGGAUUCUGUCGAGAUUGCCGUUUAAAAAGAUUGUCUUGCUCACUUUGGCUCUUUCAGUCCGGCGCUUAAGCGCCUUGCAUAAACUUCGUAGCGCAGGUUUUGCGGCGAUGGCCAACCCAGGAUACCGCUGUUCAACAUUUGUCAGAUCCUCAUGUGACGGGACACCCAAAGCAGGAUGGCGCGCUGUCUCUCAGUAUAUAGAUUUAGUUUUAGUGUGAAGUGCACGCGGCCUAGAGCGGUCACGUCAUGUAUUAGAUCGUAUUGUAGUAACAUCUACCAGCUGCGACUUUUGAACCCGGAGGAGUCCAGGCAACGUAAAAGUAUGGCGUACCACGCGACCAAAUCCCUCAUCUUACGUGUACGAAGGAAGAUACCGCAUUUUAUCGCUUAUCACUAACGCGAGCGUCUAAGCGAACAUUACUAUCCUCUAUAAAAGUUAUACGUGGCUGCUACGGUGACGUAAAGCUUUCUGUUUAAAUGCGCGCCUAAUUCCUUACUGCUAUAACAUACAUCCACCCUACCUGCCACAGUUUCCUACGACCUGGAGAAAAAUUUAAAUGGCCGAUGAUGUGUCGCCACAUACGUGAGCUGAUAGCGGAAGUGUAAA
81+
```
82+
When your cells process the DNA strip, triplets are converted to Amino Acids. This is done using the following chart:
83+
84+
![DNA](images/amino.png)
85+
( Taken from http://biobook.nerinxhs.org/bb/genetics/dna.htm )
86+
87+
We can do this ourselves (which I did the first time), but we can also use the power of the internet:
88+
http://web.expasy.org/translate/
89+
90+
Which gives the following output:
91+
```
92+
5'3' Frame 1
93+
DI-WGQSMFSGIEEHFSGTLLDPRVAGKQLDKLVDGDRTAL-HMLAYRSHL-GKELVVYH
94+
LTSLGVVLVLPFPIPYVKTSRHSMGVLRRGVLSALVHGILSRLPFKKIVLLTLALSVRRL
95+
SALHKLRSAGFAAMANPGYRCSTFVRSSCDGTPKAGWRAVSQYIDLVLV-SARGLERSRH
96+
VLDRIVVTSTSCDF-TRRSPGNVKVWRTTRPNPSSYVYEGRYRILSLITNASV-ANITIL
97+
YKSYTWLLR-RKAFCLNARLIPYCYNIHPPYLPQFPTTWRKI-MADDVSPHT-ADSGSV
98+
5'3' Frame 2
99+
TFNGVNLCSRE-KSTSAGLF-THE-PASS-IS--METAPHYSIC-LIGHTYEARS--YIT
100+
SLRWGWF-YCHFPYRM-RRRDIPWAF-GAAFSPPWFTGFCRDCRLKRLSCSLWLFQSGA-
101+
APCINFVAQVLRRWPTQDTAVQHLSDPHVTGHPKQDGALSLSI-I-F-CEVHAA-SGHVM
102+
Y-IVL--HLPAATFEPGGVQAT-KYGVPRDQIPHLTCTKEDTAFYRLSLTRASKRTLLSS
103+
IKVIRGCYGDVKLSV-MRA-FLTAITYIHPTCHSFLRPGEKFKWPMMCRHIRELIAEV-
104+
5'3' Frame 3
105+
HLMGSIYVLGNRRALQRDSFRPTSSRQAAR-ASRWRPHRTIAYASL-VTPMRQGASSISP
106+
HFAGGGFSIAISHTVCEDVETFHGRFKARRSLRPGSRDSVEIAV-KDCLAHFGSFSPALK
107+
RLA-TS-RRFCGDGQPRIPLFNICQILM-RDTQSRMARCLSVYRFSFSVKCTRPRAVTSC
108+
IRSYCSNIYQLRLLNPEESRQRKSMAYHATKSLILRVRRKIPHFIAYH-RERLSEHYYPL
109+
-KLYVAATVT-SFLFKCAPNSLLL-HTSTLPATVSYDLEKNLNGR-CVATYVS--RKCK
110+
```
111+
If you look clearly, you can see the password, which is "METAPHYSIC LIGHTYEARS". This website also solved the final hurdle: You don't have to start decoding at the first character, but at the second.
112+
113+
Pass: `METAPHYSIC LIGHTYEARS`
12114

13115
## Other write-ups and resources
14116

Loading
Loading

cyber-security-challenge-2015/digital-forensics/espionage/README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@ So the flag is _batman_
1717

1818
## Other write-ups and resources
1919

20-
* none yet
20+
* [`Cyber Security Challenge 2015: Espionage by Glenn Vandamme`](http://glennvandam.me/2015/03/cyber-security-challenge-2015-espionage/)
21+

opentoall-ctf-2015/misc/android-oh-no/README.md

+27-9
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
**Points:** 150
55
**Solves:** 14
66
**Author:** Eriner
7-
**Description:**
7+
**Description:**
88

99
> It seems someone got a hold of my phone and deleted some important files, and now my phone won't boot! I had an important app on there, maybe you can get it working! Here is an image of my phone...
10-
>
10+
>
1111
> [http://public.givemesecurity.info/16b11191c1410cb0184a6edd08e9105a.tar.gz](http://public.givemesecurity.info/OTACTF-2015/16b11191c1410cb0184a6edd08e9105a.tar.gz)
1212
>
1313
> Hint: I've encrypted my custom app so no one can find the secretz! Thankfully, I uninstalled it before someone hacked my phone! Trouble is, I can't install it on my new phone! Can you help?
@@ -18,28 +18,38 @@ This challenge revolves around finding an encrypted apk, and then decrypting it
1818
The app found here is titled: `net.opentoall.flag.flag-1.apk`. This app is a red herring, and upon opening the app, it shows a picture of a red fish and says "I'm here to distract you".
1919
This app was to be ignored, and had no useful information. It wasn't the encrypted app the challenge described.
2020
<br>
21-
<br>
2221
In the user storage directory, `mnt/android-4.4-r2/data/media/0` the file
2322
`encrypted.nothingtoseehere.apk` can be found.
24-
2523
<br>
24+
25+
A shortcut, in this case, would be to use `find` to remove the burden of manual search:
26+
> ```
27+
> shell@android ~/ # find mnt/ -type f -iname "*.apk"
28+
> mnt/android-4.4-r2/data/data/com.google.android.gms/app_dg_cache/1B1C47D6957F9C3F15E0130296C46C62216574DA/the.apk
29+
> mnt/android-4.4-r2/data/app/net.opentoall.flag.flag-1.apk
30+
> mnt/android-4.4-r2/data/media/0/encrypted.nothingtoseehere.apk
31+
> mnt/android-4.4-r2/data/media/0/Download/flag.apk
32+
> ```
33+
34+
Or,
35+
2636
```
27-
m/a/d/m/0 ❯❯❯ file encrypted.nothingtoseehere.apk
37+
shell@android ~/mnt/android-4.4-r2/data/media/0 # file encrypted.nothingtoseehere.apk
2838
encrypted.nothingtoseehere.apk: data
2939
```
3040
<br>
3141
It showing 'data' likely means that it is encrypted, as no known headers or magic numbers were found. Doing some searches, you may have found this:
3242
http://nelenkov.blogspot.com/2012/07/using-app-encryption-in-jelly-bean.html
33-
There is also a book on the topic, but I cannot find it at the time of creating this writeup.
43+
There are a few books about Android JB app encryption (i.e. "Android Security Internals") worth checking out.
3444
3545
<br>
36-
There are also a few books that cover Android JB app encryption. The most important piece of information to glean from this page is:
46+
The most important piece of information to glean from this page is:
3747
<br>
3848
3949
> The --algo, --key and --iv parameters obviously have to do with encrypted apps, so before going into details lets first try to install an encrypted APK. Encrypting a file is quite easy to do using the enc OpenSSL commands, usually already installed on most Linux systems. We'll use AES in CBC mode with a 128 bit key (a not very secure one, as you can see below), and specify an initialization vector (IV) which is the same as the key to make things simpler:
4050
4151
> ` $ openssl enc -aes-128-cbc -K 000102030405060708090A0B0C0D0E0F -iv 000102030405060708090A0B0C0D0E0F -in my-app.apk -out my-app-enc.apk `
42-
>
52+
>
4353
4454
Basically, this particular APK has been encrypted _manually_ and doesn't follow the twofish encryption Google Play uses when it encrypts the dmcrypt app-asec files. But you need a key! In the same blog post,
4555
@@ -55,7 +65,15 @@ Basically, this particular APK has been encrypted _manually_ and doesn't follow
5565
> 0000020
5666
> ```
5767
58-
As it says, the original android app encryption/decryption process uses twofish, but there is more than one way to encrypt and install apps on android. The keyfile mentioned above is also the keyfile needed to solve this challenge. Using that file as a key, you are able to decrypt the encrypted apk with openssl and grep/install to get the flag.
68+
As it says, the original android app encryption/decryption process uses twofish, but there is more than one way to encrypt and install apps on android. In this challenge, the encryption is done manually using openssl.
69+
70+
Using the keyfile mentioned above (without spaces), decrypt the `encrypted.nothingtoseehere.apk`:
71+
72+
> ```
73+
> shell@android # openssl aes-128-cbc -d -K aa7db8864627354c7a4b0fbd81f2f399 -iv 000102030405060708090A0B0C0D0E0F -in encrypted.nothingtoseehere.apk -out decrypted.nothingtoseehere.apk
74+
> ```
75+
76+
From here, grep/install to get the flag.
5977
<br>
6078
## Notes from the author:
6179
<br>

opentoall-ctf-2015/reverse/static/README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ We find that the string is used in sub\_401ECE.
2323

2424
![function sub\_401ece](ida_sub_401ece.jpg)
2525

26-
At *0x401EF2* we have the instruction `test eax, eax` which checks if eax is equal
27-
to zero.
26+
At *0x401EF2* we have the instruction `test eax, eax` which checks if eax is greater or less than, or equal to 0.
27+
2828
If `eax` equals zero the program opens a MessageBox to tell us that the
29-
password is correct.
29+
password is correct. If not, then the program makes a simple jump to address `loc_401F07` and exits.
3030

31-
How to make `eax` equals to zero ?
31+
So, our goal is clear: how to make `eax` equals to zero?
3232
`eax` contains the return value of the function called two instructions before.
3333

3434
`0x401EEF: call eax`
@@ -48,7 +48,7 @@ IDA and find that each byte of argv[1] is compared to a 14 chars buffer
4848

4949
It it matches, the function returns 0.
5050

51-
The flag is `0p3n-t0_alL___`
51+
The flag is `flag{0p3n-t0_alL___}`
5252

5353
## Other write-ups and resources
5454

opentoall-ctf-2015/reverse/switchy/README.md

+41-41
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
1111
## Write-up
1212

13-
Opening the binary in IDA, we can see 3 particular parts in the `main` function:
13+
Opening the binary in IDA, we can see 3 particular assembly parts in the `main` function:
1414

1515
* The red one which is the prologue. Basically it saves the frame pointer, changes the stack pointer and allocates some space for the function.
1616
* The green one which is in fact doing the same thing as the blue part but in a different way.
@@ -22,18 +22,18 @@ Let’s focus on what the green block is doing. Here I highlighted the parts whi
2222

2323
![IDA View 2](idaview2.png)
2424

25-
While second and third ones are just saving values which are never reused, the first one is a lot more interesting since it moves to `ecx` some data which is then moved on the stack on the next instruction. We’ll come back in these data later.
25+
While second and third ones are just saving values which are never reused, the first one is a lot more interesting since some data contained as an immediate double word moves to `ecx` register, which is then moved on the stack on the next instruction. We’ll come back to these data later.
2626

27-
We can see that a function, `sub_8048470` is then called and probably taking as argument the datas previously moved on the stack.
27+
We can see that function, `sub_8048470`, is then called and probably takes the data previously moved onto the stack as argument.
2828

29-
The remaining instructions of the block is just printing the result of the previously called function as a character on stdout and then flush stdout. The blue block is as a result equivalent to the following C code.
29+
The remaining instructions of the block (post-`lea`) just prints the result of the previously called function as a character on stdout and then flushes stdout. The blue block is as a result equivalent to the following C code.
3030

31-
```c
32-
printf("%c", sub_8048470(dword_804B058));
33-
fflush(stdout);
34-
```
31+
> ```
32+
> printf("%c", sub_8048470(dword_804B058));
33+
> fflush(stdout);
34+
> ```
3535
36-
Now let's take a look at the **sub_8048470** function:
36+
Now let's take a look at the `sub_8048470` function:
3737
3838
![IDA View 3](idaview3.png)
3939
@@ -51,42 +51,42 @@ All the offsets in `off_8048F50` lead us to the same pattern:
5151
5252
![IDA View 6](idaview6.png)
5353
54-
This is basically xoring two values and returning the result. A quick look on the values in the different blocks shows us that only the first values are always ASCII values. By the way, these ASCII values are:
54+
This is basically xoring two values and returning the result. A quick look on the values in the different blocks shows us that only the first value is always ASCII characters. By the way, these ASCII characters are:
5555
56-
```python
57-
"o gpcuabefihjmlnstw{}"
58-
```
56+
> ```
57+
> "o gpcuabefihjmlnstw{}"
58+
> ```
5959
6060
Since we can make `flag{...}` with all these letters, let’s extract them in the same order the program does with a simple IDA Python script.
6161
62-
```python
63-
from idaapi import get_byte, get_long
64-
65-
# Bytes offsets used as index in main function
66-
b = [0x804B050, 0x804B058, 0x804B060, 0x804B068, 0x804B070, 0x804B078,
67-
0x804B080, 0x804B088, 0x804B090, 0x804B098, 0x804B0A0, 0x804B0A8,
68-
0x804B0B0, 0x804B0B8, 0x804B0C0, 0x804B0C8, 0x804B0D0, 0x804B0D8,
69-
0x804B168, 0x804B0E4, 0x804B16C, 0x804B0F0, 0x804B0F8, 0x804B170,
70-
0x804B104, 0x804B174, 0x804B110, 0x804B118, 0x804B178, 0x804B124,
71-
0x804B12C, 0x804B134, 0x804B13C, 0x804B144]
72-
# Blocks offsets used to xor values
73-
o = [0x8048499, 0x80484B3, 0x80484CD, 0x80484E7, 0x8048501, 0x804851B,
74-
0x8048535, 0x804854F, 0x8048569, 0x8048583, 0x804859D, 0x80485B7,
75-
0x80485D1, 0x80485EB, 0x8048605, 0x804861F, 0x8048639, 0x8048653,
76-
0x804866D, 0x8048687, 0x80486A1]
77-
78-
# Get index values
79-
b = [get_long(x) for x in b]
80-
b = [x if x != 4294967295 else 0 for x in b] # Patch BSS datas values
81-
# Get bytes
82-
o = [get_long(x + 3) for x in o]
83-
# Get corresponding bytes
84-
f = [get_byte(o[x]) for x in b]
85-
# Convert to char
86-
f = [chr(x) for x in f]
87-
# Print result
88-
print("".join(f))
89-
```
62+
> ```
63+
> from idaapi import get_byte, get_long
64+
65+
> # Bytes offsets used as index in main function
66+
> b = [0x804B050, 0x804B058, 0x804B060, 0x804B068, 0x804B070, 0x804B078,
67+
> 0x804B080, 0x804B088, 0x804B090, 0x804B098, 0x804B0A0, 0x804B0A8,
68+
> 0x804B0B0, 0x804B0B8, 0x804B0C0, 0x804B0C8, 0x804B0D0, 0x804B0D8,
69+
> 0x804B168, 0x804B0E4, 0x804B16C, 0x804B0F0, 0x804B0F8, 0x804B170,
70+
> 0x804B104, 0x804B174, 0x804B110, 0x804B118, 0x804B178, 0x804B124,
71+
> 0x804B12C, 0x804B134, 0x804B13C, 0x804B144]
72+
> # Blocks offsets used to xor values
73+
> o = [0x8048499, 0x80484B3, 0x80484CD, 0x80484E7, 0x8048501, 0x804851B,
74+
> 0x8048535, 0x804854F, 0x8048569, 0x8048583, 0x804859D, 0x80485B7,
75+
> 0x80485D1, 0x80485EB, 0x8048605, 0x804861F, 0x8048639, 0x8048653,
76+
> 0x804866D, 0x8048687, 0x80486A1]
77+
78+
> # Get index values
79+
> b = [get_long(x) for x in b]
80+
> b = [x if x != 4294967295 else 0 for x in b] # Patch BSS datas values
81+
> # Get bytes
82+
> o = [get_long(x + 3) for x in o]
83+
> # Get corresponding bytes
84+
> f = [get_byte(o[x]) for x in b]
85+
> # Convert to char
86+
> f = [chr(x) for x in f]
87+
> # Print result
88+
> print("".join(f))
89+
> ```
9090
9191
This way, we get the flag `flag{switch jump pogo pogo bounce}`.
9292

0 commit comments

Comments
 (0)