Skip to content

Commit a92775f

Browse files
author
Jethro Beekman
committed
Mitre CTF 2014 solutions
0 parents  commit a92775f

File tree

20 files changed

+190
-0
lines changed

20 files changed

+190
-0
lines changed

Binary200a/README

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
From debugging/IDA:
2+
0 prints 'MCA-'
3+
9 prints 'Done' and invokes check routine
4+
1-8 print some character.
5+
=> PIN must be 0[1-8]{8}9 to have output match flag format.
6+
8^8 = 16M, should be brute-forceable.
7+
Also it matches against some MD5 hash, don't think there's a way around brute-forcing:
8+
gcc bf.c
9+
./a.out |./f0f09d8f2b40ccfb252654c8f4bb4171-safe |grep -B1 -m1 Granted

Binary200a/a.out

8.47 KB
Binary file not shown.

Binary200a/bf.c

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#include <stdio.h>
2+
#include <stdint.h>
3+
4+
int main(void)
5+
{
6+
char cbuf[16];
7+
uint64_t* ibuf=&cbuf;
8+
int i;
9+
for (i=0;i<16777216;i++)
10+
{
11+
write(1,"0",1);
12+
sprintf(cbuf,"%08o",i);
13+
*ibuf+=0x0101010101010101ULL;
14+
write(1,cbuf,8);
15+
write(1,"9",1);
16+
}
17+
}

Binary200b/README

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Use debugger/IDA to figure out that it matches the input against a bunch of regexes.
2+
Use regex-extract.rb to extract them from the binary.
3+
Notice that the last 3 regexes are simple per-character matches once you remove the optional characters, and they're exactly 40 chars.
4+
Intersect those regexes to find the flag.

Binary200b/regex-extract.rb

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
offset=(-0x80489e0+2528)
2+
b=[0x80489e0,0x80489ec,0x8048a38,0x8048b00,0x8048be8,0x8048ccc,0x8048f08,0x8049148]
3+
a=IO.read('0002dc53347013336adf249ff7dedc19-matchmaker').force_encoding('binary')
4+
p b.map { |i| a[(i+offset)..-1].unpack('Z*')[0] }

Binary200b/regex-test.rb

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
res=[
2+
"[\\d\\w]{40}",
3+
"[\\d]+[\\w][\\d]+[\\d][\\d]+[\\w][\\d]+[\\w]+[\\d]+[\\w]+[\\d]+[\\w]+[\\d]+[\\w]+[\\d]+",
4+
"[4-6][4-6][d-f][7-9][7-9][7-9][1-3][d-f][4-6][7-9][d-f][4-6][7-9][1-3][d-f][a-c][d-f][4-6][0-5]+[d-f][1-3][7-9][a-c][4-6][4-6][0-5]+[7-9][7-9][1-3][0-5]+[a-c][a-c][d-f][d-f][a-c][d-f][4-6][1-3][4-6]",
5+
"[246][246][ace][789][789][789][135][ace][135][789][ace][135][789][135][bdf][ace][ace][135][0-5]+[0-1]{0,5}[bdf][135][789][bdf][246][135][0-5]+[0-1]{0,5}[789][789][135][0-5]+[0-1]{0,5}[ace][ace][bdf][bdf][bdf][bdf][135][246][246]",
6+
"[34cd][56ef][56ef][789][789][789][34cd][56ef][56ef][789][56ef][56ef][789][12ab][34cd][34cd][56ef][56ef][0-5]+[34cd][34cd][789][12ab][34cd][56ef][0-5]+[789][789][12ab][0-5]+[34cd][34cd][34cd][34cd][12ab][56ef][56ef][12ab][56ef]",
7+
"[46d][rfefhr]?[46d][rfefhr]?[13e][rfefhr]?[89ba][rfefhr]?[89ba][rfefhr]?[89ba][rfefhr]?[13e][rfefhr]?[13e][rfefhr]?[57c][rfefhr]?[89ba][rfefhr]?[13e][rfefhr]?[57c][rfefhr]?[89ba][rfefhr]?[13e][rfefhr]?[46d][rfefhr]?[57c][rfefhr]?[13e][rfefhr]?[57c][rfefhr]?[02f][rfefhr]?[46d][rfefhr]?[13e][rfefhr]?[89ba][rfefhr]?[89ba][rfefhr]?[46d][rfefhr]?[57c][rfefhr]?[02f][rfefhr]?[02f][rfefhr]?[89ba][rfefhr]?[89ba][rfefhr]?[13e][rfefhr]?[02f][rfefhr]?[57c][rfefhr]?[57c][rfefhr]?[46d][rfefhr]?[46d][rfefhr]?[89ba][rfefhr]?[02f][rfefhr]?[57c][rfefhr]?[02f][rfefhr]?[46d][rfefhr]?",
8+
"[48c][gobble]?[26a][gobble]?[0def][gobble]?[48c][gobble]?[159][gobble]?[48c][gobble]?[37b][gobble]?[0def][gobble]?[159][gobble]?[48c][gobble]?[0def][gobble]?[159][gobble]?[159][gobble]?[159][gobble]?[0def][gobble]?[48c][gobble]?[0def][gobble]?[159][gobble]?[0def][gobble]?[0def][gobble]?[37b][gobble]?[48c][gobble]?[37b][gobble]?[48c][gobble]?[159][gobble]?[0def][gobble]?[0def][gobble]?[48c][gobble]?[159][gobble]?[159][gobble]?[0def][gobble]?[48c][gobble]?[48c][gobble]?[0def][gobble]?[0def][gobble]?[37b][gobble]?[0def][gobble]?[159][gobble]?[26a][gobble]?[26a][gobble]?",
9+
"[1-9][1-9][a-f][1-9][1-9][1-9][1-9][a-f][1-9][1-9][a-f][1-9][1-9][1-9][a-f][a-f][a-f][1-9][0ace][a-f][1-9][1-9][a-f][1-9][1-9][0ace][0ace][1-9][1-9][1-9][0ace][a-f][a-f][a-f][a-f][a-f][a-f][1-9][1-9][1-9]"
10+
]
11+
valid_chars=[("0".."9").to_a+("a".."z").to_a]*40
12+
res[5].gsub!("[rfefhr]?","")
13+
res[6].gsub!("[gobble]?","")
14+
res[5..7].each do |re|
15+
i=0
16+
re.gsub(/\[([^\]]+)\]/) do
17+
cc=$~[1]
18+
if cc=~/^[^-]*$/ then
19+
valid_chars[i]&=cc.chars.to_a
20+
elsif cc=~/^(.)-(.)$/ then
21+
valid_chars[i]&=(($~[1].to_s)..($~[2].to_s)).to_a
22+
else
23+
puts "Error #{cc}"
24+
exit
25+
end
26+
i+=1
27+
end
28+
end
29+
puts valid_chars.map { |v| v[0] }*""

Binary300/README

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
program calls ptrace to interfere with debugger, no matter, use LD_PRELOAD to disable:
2+
gcc -shared -fPIC -m32 ptrace.c
3+
LD_PRELOAD=./a.out ./9674ea9858c5edaa760ff4a656802999-doors
4+
5+
Then, call doors with gdb in this order:
6+
7+
doorwithkey
8+
door1
9+
door0
10+
door9001
11+
door2006
12+
door121
13+
door3
14+
door271
15+
door111970
16+
doorBlue
17+
door777
18+
door42
19+
dead end
20+
door25
21+
door5i
22+
door42
23+
dead end
24+
doorRed
25+
door34
26+
door111
27+
door87
28+
door66
29+
=> get the flag

Binary300/a.out

6.64 KB
Binary file not shown.

Binary300/ptrace.c

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
int ptrace(void)
2+
{
3+
return 0;
4+
}

Forensics100/README

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Multiple PNG files are concatenated.
2+
Use pngextract.rb to extract them all, view them to see the flag.

Forensics100/pngextract.rb

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
a=IO.read('a9b1c6694f385f27c6929cdbadf9794e-sloth.png').force_encoding('binary')
2+
i=0
3+
while n=a.index(/\x89PNG/,i+1) do
4+
IO.write("x#{i}.png",a[i...n])
5+
i=n
6+
end
7+
IO.write("x#{i}.png",a[i...-1])

Forensics300a/README

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
=> Use volatility -- http://www.volatilityfoundation.org/
2+
python vol.py imageinfo -f 4BB1D32DF7-20140626-172101.raw
3+
python vol.py hivelist -f 4BB1D32DF7-20140626-172101.raw --profile=WinXPSP3x86
4+
python vol.py hashdump -f 4BB1D32DF7-20140626-172101.raw --profile=WinXPSP3x86 -y 0xe1035b60 -s 0xe15cc008 > ~/Documents/Berke1337/MitreCTF2014/Forensics300a/hashes
5+
=> This gives a couple of LM hashes, break using http://rainbowtables.it64.com/ to get:
6+
SU94H S3CUR3
7+
7L#7XL9MQYL0BI
8+
=> These don't work, grep -ai SU94H on the memory dump to find the correct capitalization to unzip the zip and find the flag!

Forensics300a/hashes

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
*** Failed to import volatility.plugins.ssdt (NameError: name 'distorm3' is not defined)
2+
*** Failed to import volatility.plugins.mac.apihooks_kernel (ImportError: No module named distorm3)
3+
*** Failed to import volatility.plugins.linux.apihooks (ImportError: No module named distorm3)
4+
*** Failed to import volatility.plugins.malware.threads (NameError: name 'distorm3' is not defined)
5+
*** Failed to import volatility.plugins.malware.apihooks (NameError: name 'distorm3' is not defined)
6+
*** Failed to import volatility.plugins.mac.check_syscall_shadow (ImportError: No module named distorm3)
7+
*** Failed to import volatility.plugins.mac.apihooks (ImportError: No module named distorm3)
8+
Administrator:500:dfb3869d218b2854b17a474c69a9d085:83804fff7edabbc34a99f4aa1b133c99:::
9+
Guest:501:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::
10+
HelpAssistant:1000:49fceccc6e3d4049dbce689cde84fae1:96f44eb4f5e3cf212c70a0eb20436b8f:::
11+
SUPPORT_388945a0:1002:aad3b435b51404eeaad3b435b51404ee:2e2b5d20d78f296c8539003a6165278c:::

Forensics300b/README

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
First, extract the .vmdk from the .ova, and then use vmdktool [1] to turn it into a raw image.
2+
Mount the image (read-only!!!) and do some simple forensics.
3+
Find /home/georgesr/.bash_history , this talks about contract-documents.zip but it's gone...
4+
We don't know the password to contract-documents.zip.nc...
5+
No worries, we have the whole disk image, so find all potential zip headers using:
6+
=> grep -a -b -o PK f300b.img > zipoff
7+
Then, use zipreader.rb to try to read the zip headers, output the offsets for zip files with the word 'contract'.
8+
Extract the zipfile from this offset and try to unzip... the supplied password doesn't work?
9+
Search for other passwords in the disk image:
10+
=> grep -a -b -o 'zip -P..................' ~/f300b.img
11+
First match we already tried
12+
Second match is the man page or something
13+
Third uses some shell parameter, explore around this offset to find a wrapper script that appends frozenbananas to the supplied password.
14+
Supply this to unzip to find the flag.
15+
16+
[1] http://www.freshports.org/sysutils/vmdktool/

Forensics300b/zipreader.rb

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
require 'zip/zip'
2+
3+
IO.foreach('zipoff') do |line|
4+
offset=line.split(':')[0].to_i
5+
begin
6+
zio=Zip::ZipInputStream.new("f300b.img",offset)
7+
if zio then
8+
entry=zio.get_next_entry
9+
puts "#{offset} #{entry.name}" if entry and entry.name=~/contract/
10+
zio.close
11+
end
12+
rescue
13+
end
14+
end

GrabBag100/README

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Unzip
2+
Fix cstdlib-include...
3+
Play around a little with the keygen and modification times to put into srand()
4+
Nothing works...
5+
Remember there was .git
6+
=> gitk -> nothing interesting
7+
=> git branch -> shows other branch
8+
=> git checkout twig
9+
=> gitk
10+
WTF is a yellow square? Oh, look at that, it's a note with the flag.

GrabBag200a/README

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Use debugger, break panel::setSys1 and panel::disSys1
2+
Run, and type at the prompt:
3+
R
4+
T
5+
B
6+
=> debugger breaks
7+
Call disSys2..4 as well from here with the right `this'
8+
continue
9+
=> debugger breaks again
10+
Call setSys2..4 as well from here with the right `this'
11+
continue
12+
=> get a prompt
13+
type U to unlock and the flag appears!

Web100/README

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Go to directory index of missing logo
2+
"One of these is not like the others" => open File208032.html
3+
Click link
4+
Go to directory index of stylesheet
5+
Open 'THE_ORDER_IS_DEFINITELY_NOT_FOUND_IN_HERE', make things visible to read the order

Web200/README

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
There's a JS file that has to do with the login, download it.
2+
First, use some online JS beautifier for good indenting.
3+
Then copy the array on top into ruby (yay, same syntax!), and use it to replace all occurences of strings using replace_838e.rb
4+
Check the login() function for the credentials, and after follow the leads in the page source a couple times to find the flag.

Web200/replace_838e.rb

+4
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)