Score:1

How to stop outgoing brute force attack

dz flag

I got a email from my ISP that my server tried to access another server via ssh multiple times. I ran multiple scans on the hole machine and it turns up nothing.

Any idea how I can remove the malware and determine how to close the security issue?

Nmath avatar
ng flag
Don't try to salvage an installation that is compromised. It's a fool's errand. Wipe everything and start over with a new install. Evaluate your security practices and make improvements
ru flag
Shut the system off. Remove its networking. Then you have to dissect the system in question to determine what is running to make those requests and start by determining what processes are connecting outbound. Install `net-tools` first before disconnecting it from the Internet, run `sudo netstat -atupen` and watch for any items going OUT to port 22 there and see what processes are triggering, then try and find the triggering process on disk.
ru flag
Nuke it from orbit. If yo uwant to dig, keep the system in a disconnected state and evaluate it with different tools, but *removing* the malware is useless if you don't know how you were breached, so starting from clean is best solution.
Score:5
ru flag

As an IT Security expert, the proper response to any security risk of a compromised machine is: Disable the affected system(s) (shut them off entirely, or disconnect them from the network immediately and isolate them if you intend to dissect the system and the breach), and nuke it from orbit to clean it. Nuke it clean, restore important stuff from clean backups to a new reinstallation of the operating that is clean.

Once that's done, you need to make sure all your applications you have on this system need to be hardened and locked down. It's likely if you're running a web application like Wordpress or such, you need to keep that regularly patched all the time. Adding a fail2ban solution to your system and enabling it for your various applications will help so that when things trigger they get blocked at the firewall for a time period due to ongoing attack attempts.

(Properly hardening your system and the applications is a very BROAD thing that is too large for this single post, and is always a case by case analysis/basis of risk/cost reward analysis, so we can't really give you the best way to properly harden everything.)


If you really want to dissect what's going on, install net-tools on the machine that's affected, then disconnect it from the network.

sudo apt install net-tools

Once that's done, run sudo netstat -atupen and look for any connections going outbound to port 22 on your system, and see what process is triggering the port 22 connections outbound. Keep an eye on that as well and run it many times too if you need to make sure it shows up, because with no network it'll probably try and instantly fail, so running this a few times may be needed.

However, you are better off deleting everything on the system and rebuilding from scratch and keep better backups of your information that is NOT going to be malware infested.

Also, unless you know what you're doing, you shouldn't host a server, etc. on your own network because of these kinds of problems - your own systems can get breached if even one system on your home network gets popped.


To put my last bit there into perspective:

Even with my experience, all the servers on my network running Internet facing are hardened against the other servers from reaching them, and my network being built as an Enterprise-grade type network complete with managed firewall, managed switches, etc. means that my Internet facing servers are isolated into respective DMZs, and cannot reach the rest of my network where more critical data is present. Network isolation and hardening of this magnitude requires way more than what you'll get at the 'residential' and 'consumer' grade levels of equipment you can get, it requires a lot of extra time, effort, and knowledge to really isolate internet facing systems to prevent larger breaches, as well as to get net flow logging for different network behaviors, as well as filtering on active intel lists to block the known evils. It's not for the faint of heart, and requires a LOT of effort to keep it operational as well.

Two of my servers that I run in my DMZs for clients got popped recently due to improperly patched Wordpress instances. FORTUNATELY I keep backups for them, so we nuked the breached instances, restored from clean backups, and then I promptly spent six hours on each machine patching them and rehardening them. One single unpatched Wordpress instance on each of those servers led to those servers being breached and attempting to distribute Malware, which my IDS/IPS detected - again this is an Enterprise grade network setup, so I have the time, infrastructure, and money to put into it all the protections. You won't have this on your average server or residential network setup.

Marvin S. avatar
dz flag
Is there a tool that would notify me if there are many outgoing connections?
ru flag
@MarvinS. not really, take my own secured network (Enterprise-grade network and equipment) - there's TONS of connections in/out on my network a day, and though I have controls on the firewall to forbid communication with certain badness (well known bad sites, malware C2 nodes, certain countries, etc.) that requires a **very** high level of knowledge of how networks work, and for your network to be purpose built *for* such monitoring and blocking, there's nothing OOTB in Ubuntu that'll trigger "excessive connection" warnings because "excessive" is a subjective assessment.
Marvin S. avatar
dz flag
The problem seemed to be a weak user password. I changed the password to a save password and did the same with every other user I have created. Do I need to worry about any system user (e.g. www-data) that they could be breached? If there was no PID there was no program involved right? it was an active connection from the outside that caused the trouble right?
ru flag
`www-data` should have no passwords and in fact shouldn't even be able to be logged into by anyone (service only account), but without examining your system and *investigating* what happened and what commands have been executed due to 'weak user password' breaches myself, there's no way for me to give you that answer. It could have been an active conn from outside, it could have been malware installed under those users from outside that automatically runs in order to hit more targets. **Nuke your system and restore from clean backups to make sure any malware, etc. is gone from the system**
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.