A definite easy way to monitor your system is to run a command like netstat
for a day or so and see what's going outbound. For example, something like this would show all outgoing (polled) connections:
netstat -nputwc | tee ~/network.log
From there, you can check network.log
in your home folder to see if there are any weird/anomalous connections. It would be best to run this on a day when you're not going to use the internet too much, so you can get only background and not-active connections. Netstat will give you the capability to see what process is also calling the connections, which might be worthwhile to find and destroy if any scanner is running.
Furthermore, you can get a more detailed/verbose log using tcpdump
, which you can use to get more advanced output, and get more information. See man tcpdump
for more information. However, look particularly at the src
expression to only get outgoing connections. Also be sure to use the -w
option to write to a file for easy searching. You can read a bit more about tcpdump
here if you want. At the very least, this will tell you if your computer is actually scanning things.
From either of these, you can either get the process (through netstat
) or important things like when and where things are going. You can in fact run both at the same time to look for any triggers or similar that cause scans. You can even use tcpdump
to find when scans happen, and then cross-reference that with netstat
to find what process is doing things.
If you notice that these scans happen at regular times, you should look for cronjobs or similar, which can be removed (relatively) easily.
Otherwise, you can use the general security tips, such as running rkhunter
, clamav
, and so on. You could also always just reinstall your system from a known-good backup to just end it now.
And just for a bit of background on botnets, mostly to bore you.
Typically, a botnet sits idle on your system until triggered by some order. This can either be your system receiving a message from a remote server, or your machine polling a server for its new "orders." Either way, you can use these same tools to find these botnet commands, and where they're going to.
Once you can capture your machine being part of a botnet (if it is), you can find what and where the botnet software is, and remove it using any methods you want.
It may also be important to note that your computer may not be the infected device on the network. A router upstream, a WAP, a webcam, or any other sort of IoT thing (printers, even!) can also be members of a botnet. If they're behind the same connection/IP as your machine (especially at home or similar), you might be falsely blaming your computer instead of your smart toaster or whatever.
nethogs
to show network usage by process. – Byte Commander Jan 09 '17 at 11:11