Skip to content

Instantly share code, notes, and snippets.

@manesec
Created April 1, 2025 12:09
Show Gist options
  • Save manesec/6ef954efa37123178717458ba3ce3c2b to your computer and use it in GitHub Desktop.
Save manesec/6ef954efa37123178717458ba3ce3c2b to your computer and use it in GitHub Desktop.
simple clear bloodhound-ce script
#! /bin/bash
username="admin"
password="password"
send_req(){
echo "[!] Clearing container $1"
local baseurl="http://192.168.31.107:$1000"
echo "[*] Base URL: $baseurl"
local auth=$(curl -s "$baseurl/api/v2/login" -X POST -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:128.0) Gecko/20100101 Firefox/128.0' -H 'Accept: application/json, text/plain, */*' -H 'Accept-Language: en-US,en;q=0.5' -H 'Content-Type: application/json' -H "Origin: $baseurl" -H 'Connection: keep-alive' -H 'DNT: 1' -H 'Sec-GPC: 1' -H 'Priority: u=0' -H 'Pragma: no-cache' -H 'Cache-Control: no-cache' --data-raw '{"login_method":"secret","secret":"'$password'","username":"'$username'"}' | jq -r '.data.session_token')
# echo "$auth"
if [[ "$auth" == 'null' ]]; then
echo "[QAQ]: Password no currect"
exit 1
fi
# send request
curl -s "$baseurl/api/v2/clear-database" -X POST -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:128.0) Gecko/20100101 Firefox/128.0' -H 'Accept: application/json, text/plain, */*' -H 'Accept-Language: en-US,en;q=0.5' -H "Referer: $baseurl/ui/administration/database-management" -H 'Content-Type: application/json' -H "Authorization: Bearer $auth" -H "Origin: $baseurl" -H 'Connection: keep-alive' -H 'DNT: 1' -H 'Sec-GPC: 1' -H 'Priority: u=0' -H 'Pragma: no-cache' -H 'Cache-Control: no-cache' --data-raw '{"deleteCollectedGraphData":true,"deleteDataQualityHistory":true,"deleteFileIngestHistory":true,"deleteAssetGroupSelectors":[1,2]}'
echo "[*] OK!"
}
clear_func() {
if [ $# -ne 1 ]; then
exit 1
fi
local input=$1
case $input in
1|2|3|4|5)
send_req $1
;;
all)
echo "[*] Clear all container ..."
send_req 1
sleep 3
send_req 2
sleep 3
send_req 3
sleep 3
send_req 4
sleep 3
send_req 5
;;
*)
echo "clear-bloodhound <1/2/3/4/5/all>"
exit 1
;;
esac
}
clear_func "$1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment