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
|
~ ssh -p 2223 leviathan5@leviathan.labs.overthewire.org
leviathan5@leviathan:~$ ls -al
total 28
drwxr-xr-x 2 root root 4096 May 10 18:27 .
drwxr-xr-x 10 root root 4096 May 10 18:27 ..
-rw-r--r-- 1 root root 220 May 15 2017 .bash_logout
-rw-r--r-- 1 root root 3526 May 15 2017 .bashrc
-rw-r--r-- 1 root root 675 May 15 2017 .profile
-r-sr-x--- 1 leviathan6 leviathan5 7764 May 10 18:27 leviathan5
leviathan5@leviathan:~$ file leviathan5
leviathan5: setuid ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=ed6f1fe71c4b82ecb323211e4c9b79fa3f8c09ca, not stripped
leviathan5@leviathan:~$ ./leviathan5
Cannot find /tmp/file.log
leviathan5@leviathan:~$ vim /tmp/file.log
leviathan5@leviathan:~$ cat /tmp/file.log
It's file.log
leviathan5@leviathan:~$ ./leviathan5
It's file.log
leviathan5@leviathan:~$ ./leviathan5
Cannot find /tmp/file.log
leviathan5@leviathan:~$ vim /tmp/file.log
leviathan5@leviathan:~$ cat /tmp/file.log
It's file.log
leviathan5@leviathan:~$ ltrace ./leviathan5
__libc_start_main(0x56555760, 1, 0xffffd744, 0x56555840 <unfinished ...>
fopen("/tmp/file.log", "r") = 0x56558008
fgetc(0x56558008) = 'I'
feof(0x56558008) = 0
putchar(73, 0x565558c0, 1, 0x56555777) = 73
fgetc(0x56558008) = 't'
feof(0x56558008) = 0
putchar(116, 0x565558c0, 1, 0x56555777) = 116
fgetc(0x56558008) = '''
feof(0x56558008) = 0
putchar(39, 0x565558c0, 1, 0x56555777) = 39
fgetc(0x56558008) = 's'
feof(0x56558008) = 0
putchar(115, 0x565558c0, 1, 0x56555777) = 115
fgetc(0x56558008) = ' '
feof(0x56558008) = 0
putchar(32, 0x565558c0, 1, 0x56555777) = 32
fgetc(0x56558008) = 'f'
feof(0x56558008) = 0
putchar(102, 0x565558c0, 1, 0x56555777) = 102
fgetc(0x56558008) = 'i'
feof(0x56558008) = 0
putchar(105, 0x565558c0, 1, 0x56555777) = 105
fgetc(0x56558008) = 'l'
feof(0x56558008) = 0
putchar(108, 0x565558c0, 1, 0x56555777) = 108
fgetc(0x56558008) = 'e'
feof(0x56558008) = 0
putchar(101, 0x565558c0, 1, 0x56555777) = 101
fgetc(0x56558008) = '.'
feof(0x56558008) = 0
putchar(46, 0x565558c0, 1, 0x56555777) = 46
fgetc(0x56558008) = 'l'
feof(0x56558008) = 0
putchar(108, 0x565558c0, 1, 0x56555777) = 108
fgetc(0x56558008) = 'o'
feof(0x56558008) = 0
putchar(111, 0x565558c0, 1, 0x56555777) = 111
fgetc(0x56558008) = 'g'
feof(0x56558008) = 0
putchar(103, 0x565558c0, 1, 0x56555777) = 103
fgetc(0x56558008) = '\n'
feof(0x56558008) = 0
putchar(10, 0x565558c0, 1, 0x56555777It's file.log
) = 10
fgetc(0x56558008) = '\377'
feof(0x56558008) = 1
fclose(0x56558008) = 0
getuid() = 12005
setuid(12005) = 0
unlink("/tmp/file.log") = 0
+++ exited (status 0) +++
|