
提权思路:
首先对目录爆破得到一个加密的文件,对其进行解密,发现为ssh私钥,然后通过ssh2john再次解密,赋予权限,执行得到一个ssh.key,然后ssh远程登录,提权使用sudo中的二进制pip提权
查看本机ip 192.168.10.128
扫描靶机ip
nmap -sP 192.168.10.0/24
查看开放端口 nmap -p- 192.168.10.131
开放了20、80端口
端口探测
-A:可以进行操作系统检测、版本检测、脚本扫描、路由追踪
访问80端口
没有可以利用信息
目录扫描
gobuster dir -u http://192.168.10.131 -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -x .php,.txt,.html,.zip
dir:目录扫描
-u:url
-w:字典
-x:后缀名
爆破出robots.txt文件,访问这个文件
发现一个~myfiles目录,进行访问
404界面
继续访问manual目录
依然没有找到可以利用信息
继续进行目录爆破
ffuf -u http://192.168.10.131/~FUZZ -c -w /usr/share/wordlists/dirb/common.txt
得到~secret目录,访问
继续爆破~secret目录
ffuf -u http://192.168.10.131/~secret/.FUZZ -c -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -e .txt,.pub,.html,.bak -mc 200
得到一个mysecret.txt文件
访问得到一串密文
没有数字”0“,
没有字母大写”O“、和大小写的”I“
没有字符”+“、”/“
猜测为BASE58加密方式
解密拿到秘钥
解密完成发现是ssh的私钥
将密钥写入kali的.ssh文件夹内
vi ssh.key :编辑一个文件,文件内容为解密后的内容
ssh2john.py ssh.key > hash: 将 SSH 私钥文件转换成 John the Ripper 可以理解的格式,以便进行密码破解
得到一个hash
对生成的hash再次解密
john --wordlist=/usr/share/wordlists/fasttrack.txt hash
给密钥ssh.key授权,权限为600
ssh登录
拿到shell
拿到第一个flag
下一步提权
常见的提权方式内核提权、sudo提权、suid提权
find / -perm -u=s -type f 2>/dev/null
对提权信息收集
这里有sudo,可以试试sudo提权
sudo -l
有一个heist.py文件
查看一下
发现导入的是webbrowser
查找这个webbrowser
find /usr -name *webbrowser*
查看权限
ls -alh /usr/lib/python3.9/webbrowser.py
在这个文件里面写入shell
vi /usr/lib/python3.9/webbrowser.py
执行shell
二进制pip提权
输入pip,点击sudo
这里有sudo提权
复制下方代码然后执行
成功拿到root权限
拿到第二个flag
总结:
使用工具
目录扫描工具:
gobuster
gobuster -h帮助文档
gobuster dir -h 目录扫描功能,使用dir参数,查看帮助文档
参数解释
dir:目录扫描
-u:url
-w:字典
-x:后缀名
使用:gobuster dir -u http://192.168.10.131 -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -x .php,.txt,.html,.zip
目录爆破工具:
ffuf
-mc 为响应码
-c 高亮显示
-e 过滤文件扩展名
使用:ffuf -u http://192.168.10.131/~FUZZ -c -w /usr/share/wordlists/dirb/common.txt
站长之家解密工具
如需授权、对文章有疑问或需删除稿件,请联系 FreeBuf 客服小蜜蜂(微信:freebee1024)