How to install BFD (Brute Force Detection) Published: Jan 21, 2004
  • Rating

    5/5

If you are renting a server then chances are you only have one big partition. Learn how to create a secure /tmp partition even while your server is already up and running on Cpanel/WHM.

Securing Your /tmp Partition with Cpanel/WHM

If you are renting a server then chances are everything is lumped in / and a small amount partitioned for /boot and some for swap. With this current setup, you have no room for making more partitions unless you have a second hard-drive. Learn how to create a secure /tmp partition even while your server is already up and running.
Recently, I found out it would be worthwhile to give /tmp it's own partition and mount it using noexec- This would protect your system from MANY local and remote exploits of rootkits being run from your /tmp folder.

What we are doing it creating a file that we will use to mount at /tmp. So log into SSH and SU to root so we may being!

code:
cd /dev

Create 100MB file for our /tmp partition. If you need more space, make count size larger.

code:
dd if=/dev/zero of=tmpMnt bs=1024 count=100000

Make an extended filesystem for our tmpMnt file

code:
/sbin/mke2fs /dev/tmpMnt

Backup your /tmp dir- I had mysql.sock file that I needed to recreate the symbolic link for. Other programs may use it to store cache files or whatever.

code:
cd /

code:
cp -R /tmp /tmp_backup

Mount the new /tmp filesystem with noexec

code:
mount -o loop,noexec,nosuid,rw /dev/tmpMnt /tmp

code:
chmod 1777 /tmp

Copy everything back to new /tmp and remove backup

code:
cp -R /tmp_backup/* /tmp/

code:
rm -rf /tmp_backup

Now we need to add this to fstab so it mounts automatically on reboots.

code:
pico -w /etc/fstab

You should see something like this:
code:
/dev/hda3               /                       ext3    defaults,usrquota        1 1
/dev/hda1               /boot                   ext3    defaults        1 2
none                    /dev/pts                devpts  gid=5,mode=620  0 0
none                    /proc                   proc    defaults        0 0
none                    /dev/shm                tmpfs   defaults        0 0
/dev/hda2               swap                    swap    defaults        0 0

At the bottom add
code:
/dev/tmpMnt             /tmp                    ext2    loop,noexec,nosuid,rw  0 0

(Each space is a tab)
Save it!
Ctrl + X and Y

Your done- /tmp is now mounted as noexec. You can sleep a little bit safer tonight. I created a hello world c++ and compiled it then moved it to /tmp. Upon trying to run it (even chmod +x'ed), it gives the following error:

code:
bash: ./a.out: Permission denied

Yay! /tmp no longer has execute permissions :-D

  • Rating

    5/5

Related Articles

Comments (36)

  • Gravatar - Olly
    Olly 15:26, January 21, 2004
    What if your IP isnt static, (if you are talking about the ip which you use to connect, not your box ip) how would you get around this problem?
  • Gravatar - Mike
    Mike 02:14, January 23, 2004
    "What if your IP isnt static, (if you are talking about the ip which you use to connect, not your box ip) how would you get around this problem? "

    I was wondering the same thing, what if your IP isn't static.
  • Gravatar - matlex
    matlex 04:49, January 27, 2004
    I think its simple then.

    Add the whole IP range of your ISP.

    for example:
    If you ISP IP range
    12.234.345.0-12.234.345.255

    Add just this:
    12.234.345
  • Gravatar - bman
    bman 19:37, February 14, 2004
    any idears how to fix this ?
    tail -f /var/log/bfd_log
    Feb 14 20:35:00 xxxxxx BFD(8570): could not locate $FWFILE, aborting.
  • Gravatar - Alex
    Alex 15:03, March 16, 2004
    could not locate $FWFILE is because you didnt installed APF before
  • Gravatar - Ryan
    Ryan 23:48, July 20, 2004
    Q: what if 1, you dont have static ips, and 2, your isp has more then 2 b class ip blocks? as i dont want to add them all and open it upto all 3 1/4 million users they host.
  • Gravatar - pierre
    pierre 19:17, August 19, 2004
    how to install BFD can you write the command pls .<br />
    thank you
  • Gravatar - Nonel S. Pagdato
    Nonel S. Pagdato 09:12, October 4, 2004
    Hi, is there any BFD application for any flavor of microsoft server, hope to hear from you soon, thanks..
  • Gravatar - netcopan
    netcopan 16:58, December 19, 2004
    should we add it into cron? After I restart server it will still be there??
  • Gravatar - Steel Rat
    Steel Rat 22:05, January 12, 2005
    Also a line on how to have BFD startup automatically (unless it's tied to APF in that regard...
  • Gravatar - Alan
    Alan 22:39, January 21, 2005
    >Q: what if 1, you dont have static ips<br />
    <br />
    don't get your password wrong <br />
    <br />
    :)
  • Gravatar - Matrafox
    Matrafox 09:18, March 23, 2005
    >Q: what if 1, you dont have static ips<br />
    <br />
    Then if u type rong password and u are banned, u just have to reboot your machine to take another Ip, and just try again :)
  • Gravatar - xaver
    xaver 02:38, April 2, 2005
    "There is an included 'install.sh' script that installs all files to<br />
    '/usr/local/bfd/' and places a 8-minute cronjob in '/etc/cron.d/bfd'. The setup<br />
    is really as simple as that."
  • Gravatar - Chris
    Chris 00:03, July 22, 2005
    Thanks works perfect.
  • Gravatar - robbert
    robbert 16:00, August 8, 2005
    many thnx! works perfect!!!!
  • Gravatar - Mike
    Mike 00:37, September 6, 2005
    It would help ppl if you actually gave some good examples of what configurations are preferable on a cPanel or other server, all you are doing here is stating the contents on the RFX site or in a README.
  • Gravatar - yenren
    yenren 13:05, September 11, 2005
    do we have to restart bdf manually everytime we restarted server?
  • Gravatar - grabt
    grabt 10:58, October 22, 2005
    How to stop BFD
  • Gravatar - sam
    sam 11:44, January 18, 2006
    Its realy good!
  • Gravatar - Alexender
    Alexender 08:21, March 5, 2006
    grabt:<br />
    <br />
    to stop BFD , type<br />
    <br />
    /usr/local/sbin/bfd -s <br />
    <br />
    <br />
  • Gravatar - Luis
    Luis 02:49, March 15, 2006
    I actully managed to lock myself out of my server the other day after a few typing errors when trying to login... just went and turned my linksys router off, waited a few minutes and then reconnected... I had another IP and was able to enter again.
  • Gravatar - James Tervit
    James Tervit 19:07, April 17, 2006
    Installed BFD along with a few minor changes to my ports and it stopped failed authentications dead in its tracks..... very cool
  • Gravatar - Ramkriz
    Ramkriz 20:21, July 31, 2006
    BFD is not working with the default rules. Please give me some rules for BFD.<br />
    <br />
    Thanks.
  • Gravatar - Alan
    Alan 10:55, August 17, 2006
    does this bruteforce auto start with system reboot?
  • Gravatar - Jose
    Jose 06:52, September 14, 2006
    Q: Can i type in ignore hosts my dyndns host?<br />
    <br />
    Ex. abcdefg.dyndns.org<br />
    <br />
    Thanks for you teach
  • Gravatar - hello123
    hello123 05:51, October 25, 2006
    how to check whether BFD is started
  • Gravatar - Turkulerdiyari
    Turkulerdiyari 22:08, November 17, 2006
    I get this error :<br />
    could not locate $TLOGP, aborting.<br />
    <br />
    How can i fix this problem.
  • Gravatar - sss
    sss 11:51, January 16, 2007
    Really gud one
  • Gravatar - ePak
    ePak 22:09, February 1, 2007
    Q: Do I have to restart bfd everytime the server reboots?<br />
    <br />
    A: No. BFD is not a daemon. There is a cron that runs every 10 minutes that sweets the logs for "attacks." So basically, every 10 minutes, it runs on its own. Location of cron: /etc/cron.d/bfd<br />
    <br />
    <br />
    Q: How do I disable BFD?<br />
    <br />
    A: You can remove the cron from /etc/cron.d/bfd or you can use the uninstall script that came in the BFD tar.<br />
    <br />
    I like the script, but my question is, how many lines does it take to cause an IP block?
  • Gravatar - Radu
    Radu 15:55, February 23, 2007
    Has anybody try to install on suse ? Or
  • Gravatar - alex
    alex 22:39, March 18, 2007
    My bfd can't trace proftpd attack, why?<br />
    Can anyone help me?<br />
    Mar 18 22:23:47 ServerFTP proftpd[8035]: ServerFTP (82.191.154.xxx[82.191.154.xxx]) - USER anonymous: no such user found from 82.191.154.xxx [82.191.154.xxx] to 80.21.159.xxx:21
  • Gravatar - Riaan
    Riaan 21:52, September 24, 2007
    Hi there<br />
    <br />
    How can I change the rules so that bfd will block an IP after 2 attempt and what is the default attempts?
  • Gravatar - Tim
    Tim 14:10, October 13, 2007
    RE: Alexander<br />
    <br />
    /usr/local/sbin/bfd -s<br />
    <br />
    That does not STOP bfd, it runs it with standard output. BFD doesn't run as a service, but as cron job. So you'd have to remove the cron job as staed by ePak
  • Gravatar - Sabarish......
    Sabarish...... 21:44, January 20, 2008
    Hi Riaan,<br />
    <br />
    BFD is configured to block after 10 attempts. See the TRIG value inside the files on /usr/local/bfd/rules<br />
    <br />
    Let us know through mail, if u need any further assistance.
  • Gravatar - JT
    JT 18:29, September 26, 2008
    After restarting BFD, I got the following:<br />
    <br />
    /usr/local/sbin/bfd -s<br />
    BFD version 0.9 <bfd@r-fx.org><br />
    Copyright (C) 1999-2004, R-fx Networks <proj@r-fx.org><br />
    Copyright (C) 2004, Ryan MacDonald <ryan@r-fx.org><br />
    This program may be freely redistributed under the terms of the GNU GPL<br />
    <br />
    /usr/local/bfd/tlog: line 71: [: : integer expression expected<br />
    /usr/local/bfd/tlog: line 74: [: : integer expression expected<br />
    <br />
    What is the tlog bit mean? Please help...
  • Gravatar - dt
    dt 06:51, August 6, 2009
    I installed afp. ran it. see it in the log. then install bfd. ran it numerous times. nothing happens other than printing the copyright message, no matter what params I enter. i try failed logins from my other servers over and over and nothing happens. huge messages logfiles, doesn't seem to even try to scan trhem. bfd log file is completely empty. what is wrong? tried this on 2 servers, both didnt work

Add Your Thoughts

WebHostGear.com is a hosting directory, not a web host.

Copyright © 1998-2017 WebHostGear.com