Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions ebury/detect_ebury.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,18 @@ declare -A ebury_socket_addr=(
["event-lqG1FF5dwG"]="1.8.2.e6"
)

# Detect Ebury abstract UNIX socket based on regex.
add_generic_socket() {
local s

s="$(grep -Eom1 '@(event-[a-zA-Z0-9]{10}|/dev/(event|stats)-[a-zA-Z0-9]{10}|UDEV-[a-zA-Z0-9]{8}|/run/systemd/log|/proc/udevd)' /proc/net/unix)"
s="${s:1}"
# /tmp/dbus-[a-zA-Z0-9]{10} is a common name, but Ebury has only 1 per master process.
[ -z "$s" ] && s="$(grep -E '@/tmp/dbus-[a-zA-Z0-9]{10}' /proc/net/unix | sed 's|.*@||g' | sort | uniq -c | grep " 1 " | awk '{print $2}' | head -n1)"
[ -z "$s" ] && return
ebury_socket_addr["$s"]="Ebury of unknown version"
}

# Finds the PID of the Ebury process from the inode of the UNIX socket
function find_ebury_pid() {
find /proc -maxdepth 3 -lname "socket:\[$1\]" 2> /dev/null | cut -d/ -f 3
Expand Down Expand Up @@ -93,6 +105,7 @@ function retry_with_rootkit_evastion {
function detect() {
local RED='\033[0;31m'
local CLEAR='\033[0m'
add_generic_socket
for socket in "${!ebury_socket_addr[@]}"; do
if abstract_unix_socket_exists "$socket"; then
echo -n -e "${RED}Found abstract UNIX socket \"$socket\" for "
Expand Down