hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : Hosting Security and Technology : Hosting Security and Technology Tutorials : Protect yourself from brute-forcers!
Reply

Hosting Security and Technology Tutorials Tutorials related to server security or the like.
Forum Jump

Protect yourself from brute-forcers!

Reply Post New Thread In Hosting Security and Technology Tutorials Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old 07-29-2006, 11:16 AM
vx|brian vx|brian is offline
Aspiring Evangelist
 
Join Date: Jul 2006
Location: Montreal, Canada
Posts: 369

Protect yourself from brute-forcers!


Hello everyone!

I have been new in the hosting industry but the security was never new for me, I hardened and did all the methods to secure my server. As a very new company and getting sales only from AdWords, I didn't expect my hardening a need but still did it.

Until today, I recieved an email from my server notifying me that someone was actually trying to brute-force into the server so I thought I'd make a tutorial how to protect yourself.

First, you'll need APF to be installed, I'm not going to go in details on how to setup the firewall, but you'll simply need it install so that BFD (brute force detector) can block the IP from trying to "brute force".

Installing APF
cd ~
wget http://www.rfxnetworks.com/downloads/apf-current.tar.gz
tar -xvzf apf-current.tar.gz
rm -f apf-current.tar.gz
cd apf-*
sudo sh install.sh

Installing BFD
cd ~
wget
http://www.rfxnetworks.com/downloads/bfd-current.tar.gz
tar -xvzf bfd-current.tar.gz
rm -f bfd-current.tar.gz
cd bfd-*
sudo sh install.sh

Configuring BFD
Use your favorite text editor (I prefer nano) to edit the configuration file,
/usr/local/bfd/conf.bfd

Find
ALERT_USR="0"
and replace it with
ALERT_USR="1"

Find
EMAIL_USR="root"
and replace it with
ALERT_USR="your.email@webserver.com"

Save your modifications and exit your editor, start BFD using the line
/usr/local/sbin/bfd -s

Now, whenever BFD will detect a bruteforce, it will email you at the email set above & BFD will run the command
/etc/apf/apf -d the.attackers.ip

The emails you will usually recieve look like this:
Jul 29 08:22:40 yourhostname sshd[21642]: Invalid user manfred from the.attackers.ip
Jul 29 08:22:40 yourhostname sshd[21643]: Invalid user michi from the.attackers.ip
Jul 29 08:22:42 yourhostname sshd[21642]: Failed password for invalid user manfred from the.attackers.ip port 48215 ssh2
Jul 29 08:22:42 yourhostname sshd[21643]: Failed password for invalid user michi from the.attackers.ip port 48223 ssh2
Jul 29 08:22:44 yourhostname sshd[21646]: Invalid user michi from the.attackers.ip
Jul 29 08:22:47 yourhostname sshd[21646]: Failed password for invalid user michi from the.attackers.ip port 48322 ssh2
Jul 29 08:22:47 yourhostname sshd[21647]: Failed password for postgres from the.attackers.ip port 48329 ssh2
Oh, and one thing I have done after I recieved the attack, I immeditaly changed the default SSH port. Use your favorite text editor (nano again!) to edit /etc/ssh/sshd_config

Find
#Port 22
And uncomment the line (Remove the #) and replace the 22 by the port you want SSH to use (Max. port number is
49151 so make sure you don't put anything past that. Afterwards, restart SSH. Usually on CentOS it is service sshd restart and in other operating systems, it is /etc/rc.d/init.d/sshd restart

After getting attacked, I did a WHOIS on the IP (Run whois the.attackers.ip). You'll usually see one of the emails something like abuse@somedomain.com.

Make sure to send them an email including the logs from the email, your server IP and the attackers IP.

Thanks alot for reading

Reply With Quote


Sponsored Links
  #2  
Old 07-30-2006, 08:04 AM
herzigint herzigint is offline
New Member
 
Join Date: Jul 2006
Posts: 0
Great tutorial ! Easy to follow and about a subject not to be missed! Thanks!

-Sebastian

Reply With Quote
  #3  
Old 07-30-2006, 08:30 AM
grandad grandad is offline
Web Hosting Master
 
Join Date: Mar 2002
Location: UK
Posts: 1,262
Is this compatible with Frontpage extensions being used on a server?

Reply With Quote
Sponsored Links
  #4  
Old 07-30-2006, 10:33 AM
vx|brian vx|brian is offline
Aspiring Evangelist
 
Join Date: Jul 2006
Location: Montreal, Canada
Posts: 369
Quote:
Originally Posted by grandad
Is this compatible with Frontpage extensions being used on a server?
I don't see any reasons why it wouldn't. My server runs cPanel with Frontpage and it causes no problems.

Reply With Quote
  #5  
Old 07-30-2006, 11:58 AM
nick125 nick125 is offline
WHT Addict
 
Join Date: Mar 2006
Location: Albuquerque, New Mexico
Posts: 142
I use denyhosts, and it works pretty well for me. The main issue with using something that adds the offending host to a firewall is that, if the attacker had access to enough hosts, they could potentially cause a DDoS effect to the server, and potentially crash the server. Denyhosts just adds the offending host to the /etc/hosts.deny file. One of the best features of denyhosts is the sync feature, which stops most attacks before they even start attacking your server. I love it

Reply With Quote
  #6  
Old 07-31-2006, 05:35 AM
herzigint herzigint is offline
New Member
 
Join Date: Jul 2006
Posts: 0
WOW! Installed it yesterday and got my first message today in the morning! LOL! Did a whois, and it seemed to have come from a computer company... anyway, I initiated the necessary steps!

-Sebastian

Reply With Quote
  #7  
Old 08-01-2006, 04:08 PM
tamar tamar is offline
Junior Guru
 
Join Date: May 2006
Posts: 232
Very nice tutorial!

Thanks for sharing.

Reply With Quote
  #8  
Old 09-15-2006, 10:38 AM
Gazza-t Gazza-t is offline
Junior Guru Wannabe
 
Join Date: Jun 2006
Posts: 33
i allready have APF & BFD installed, changed port etc,
can port 22 totally be closed in the firewall ??

thank you

Reply With Quote
  #9  
Old 09-15-2006, 04:35 PM
vx|brian vx|brian is offline
Aspiring Evangelist
 
Join Date: Jul 2006
Location: Montreal, Canada
Posts: 369
Once you changed ports and SSH is not at port 22. It is considered as a closed port, you don't need to close it.

Reply With Quote
  #10  
Old 09-15-2006, 10:10 PM
HD Fanatic HD Fanatic is offline
Web Hosting Master
 
Join Date: Jan 2005
Posts: 2,099
does BFD autorun at boot?

Reply With Quote
  #11  
Old 09-16-2006, 09:43 AM
vx|brian vx|brian is offline
Aspiring Evangelist
 
Join Date: Jul 2006
Location: Montreal, Canada
Posts: 369
Yes, it will start. It's run by a timed cronjob so it will run when you boot your server/computer.

Reply With Quote
  #12  
Old 09-19-2006, 09:40 AM
Gazza-t Gazza-t is offline
Junior Guru Wannabe
 
Join Date: Jun 2006
Posts: 33
Quote:
Originally Posted by vexxhost
Once you changed ports and SSH is not at port 22. It is considered as a closed port, you don't need to close it.
thanks for your reply

Reply With Quote
  #13  
Old 09-19-2006, 04:36 PM
vx|brian vx|brian is offline
Aspiring Evangelist
 
Join Date: Jul 2006
Location: Montreal, Canada
Posts: 369
No problem.

Reply With Quote
  #14  
Old 09-19-2006, 04:46 PM
Digiover Digiover is offline
Newbie
 
Join Date: Apr 2004
Location: the Netherlands
Posts: 6
Quote:
Originally Posted by nick125
I use denyhosts, and it works pretty well for me. The main issue with using something that adds the offending host to a firewall is that, if the attacker had access to enough hosts, they could potentially cause a DDoS effect to the server, and potentially crash the server. Denyhosts just adds the offending host to the /etc/hosts.deny file. One of the best features of denyhosts is the sync feature, which stops most attacks before they even start attacking your server. I love it
Why not just add your IP address to /etc/hosts.allow (for the service sshd) and deny all others? That is, if you are not offering ssh access to your customers of course.
I am no fan of binding sshd to an alternate port, therefor this is my favorite solution.

Reply With Quote
  #15  
Old 09-19-2006, 06:44 PM
vx|brian vx|brian is offline
Aspiring Evangelist
 
Join Date: Jul 2006
Location: Montreal, Canada
Posts: 369
However, Digiover. Most ISP's here in Canada & USA do -not- have static IPs, means if you reconnect or get disconnected, you're pretty much locked out. :-)

Reply With Quote
Reply

Related posts from TheWhir.com
Title Type Date Posted
6Scan Sees Surge of Malicious Attempts During WordPress Attack Web Hosting News 2013-04-18 18:36:19
Incapsula Program Helps Web Hosts Protect Against Brute Force WordPress Attacks Web Hosting News 2013-04-17 12:13:49
Noise Filter: WordPress Attacks Hammer Web Hosts Web Hosting News 2013-04-15 15:06:45
Juniper Networks Updated Mykonos Web Security Software Stops Hackers in Real-time Web Hosting News 2012-05-30 11:57:21
Web Host FireHost Prevents 50 Million Cyberattacks, Looks to Expand Global Team Web Hosting News 2011-12-08 20:01:32


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?