I'm trying to build a shell script which can automatically detect malware, backdoors and rootkits and I'm trying to research for it. I found some of the things like

find . -name “*.js” | xargs grep -l “eval(unescape”
find . -name “*.php” | xargs grep -l “eval(base64_decode” 

But I dont find only these relevant to just find for .php and .js files and try to see if it consists of malware. Can anyone please help me to give a general idea that I can use for the script so that it can do the work of malware, backdoors and rootkits detection. More precisely to say how can one find these malwares, backdoors and rootkits on a ubuntu system. Thanks.

  • Looking for fixed strings in a dynamic language is a bit of a non-starter, since there are always more ways of obfuscating the operation you're trying to detect. In the first example you could replace eval with e=window["ev"+"al"];e, for instance.
    – chronitis
    Jul 29, 2013 at 9:12

1 Answer 1


You ask about 3 different things...

  1. Root kits;
  2. Backdoors;
  3. Malware.

Root kits

Most root kits use the kernel to hide themselves and they are only visible from within the kernel.

If you want to know how to find them why not use the power of open source and install rkhunter and see how they do it? You can find the source here.

Besides that CERT has a thorough explanation on what to look for when dealing with root kits. Highlights from the link:

  • Examine log files for connections from unusual locations or other unusual activity
  • Look for setuid and setgid files (especially setuid root files) everywhere on your system

    find / -user root -perm -4000 -print
    find / -group kmem -perm -2000 -print
  • Check your system binaries to make sure that they haven't been altered.

  • Examine all the files that are run by 'cron' and 'at.'
  • Check for unauthorized services.
  • Examine the /etc/passwd file on the system and check for modifications to that file.
  • Check your system and network configuration files for unauthorized entries.
  • Look everywhere on the system for unusual or hidden files (files that start with a period and are normally not shown by 'ls').

Most of these you can do from command line.

Also worth reading:


The problem with backdoors is that they generally are flaws in software that get abused. The basic set of rules...

  1. immediately install security updates when you're notified;
  2. do not install antivirus, as you really don't need it in Linux; unless you share files with Windows
  3. enable the firewall (sudo ufw enable) without further tweaks;
  4. stick to the official repo's as much as possible, and only deviate from them when strictly necessary and with much caution;
  5. keep Java (both openJDK and Oracle Java) disabled by default in your browser, and only enable it when needed;
  6. use Wine with caution;
  7. and most important of all: use your common sense. The biggest security threat is generally found between keyboard and chair.

Worth reading:


Scan /etc/hosts for weird IP adresses and host names. If you look at these:

either a browser extension or an alteration to /etc/hosts is the cause.

Also a good read is:


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .