#!/bin/bash

# Define paths and filenames
sources_list="/etc/apt/sources.list.d/freedownloadmanager.list"
collect_file="/etc/cron.d/collect"
directories="/var/tmp /lost+found /lib /lib64 /etc/openal /etc/thermald"
virus_files="crond bs"
infection_indicator="deb.fdmpkg.org"
detected=0

echo "Checking for virus infection..."

# Source list check
if grep -q "$infection_indicator" $sources_list 2>/dev/null; then
    echo "$sources_list contains a suspicious source."
    detected=1
fi

# Crontab file check
if [ -f $collect_file ] ; then
    echo "$collect_file exists."
    detected=1
fi

# Directory check for virus files
for dir in $directories; do
    for file in $virus_files ; do
        if [ -f $dir/$file ]; then
            echo "Suspicious file found $dir/$file."
            detected=1
        fi
    done
done

# APT key check
if apt-key list 2>/dev/null | grep -q "B6D0 9383"; then
    echo "Suspicious APT key found."
    detected=1
fi

# Check crond process

if pgrep -x "crond" > /dev/null ; then
    echo "Suspicious process crond found."
    detected=1
fi

if [ $detected == 0 ] ; then 
    echo "No signs of infection found."
else
    echo "It is highly likely that your system is infected. We strongly recommend checking it with antivirus software or reinstalling it."
fi

