Skip to content

Instantly share code, notes, and snippets.

@rexcze-zz
Last active May 17, 2017 08:23
Show Gist options
  • Save rexcze-zz/14d6e0bbba96eed388bc481903ac38c8 to your computer and use it in GitHub Desktop.
Save rexcze-zz/14d6e0bbba96eed388bc481903ac38c8 to your computer and use it in GitHub Desktop.
#!/bin/bash
#This script needs to be run by root or with root privileges (which is far better)
#check distribution to use right tools
if [ -f /etc/redhat-release ]; then
PKG="rpm -qf"
else
PKG="dpkg -S"
fi
#get all running pids
PIDS=`ps aux|awk '{ print $2 }'`
#get all binary to pids
BINARY=`for PID in ${PIDS}; do lsof -p ${PID} 2>/dev/null |grep txt|awk '{ print $9 }' ; done|sort |uniq`
#List the bad guys
for BIN in ${BINARY}
do
${PKG} "${BIN}" &> /dev/null
if [[ $? -gt 0 ]] ;then
echo -e "\e[1m\e[31m[FALSE]\e[0m ${BIN}"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment