Protecting roundcube against bruit force attacks

You probably have protected your dovecot, postfix, exim, dbmail, or any other port opening application that needs to be protected from bruit force and dictionary attacks.

But what about roundcube, the problem with roundcube is that you have to whitelist it (whether it is on the same server or a different server) so that it does not get blocked, so now you have another security issue, this way a hacker can bruit force your server even when fail2ban is monitoring all SMTP and IMAP and POP ports.

The solution to this is to actually protect RoundCube itself against bruit force.

Forget the apache logs, we don’t need to use those as roundcube will log failed attempts in it’s /logs/errors file, this file has something similar to the following line

IMAP Error: Login failed for from AUTHENTICATE PLAIN: Authentication failed

You should also note that there is a certain roundcube config file in fail2ban, which i am not using because i like to make things as simple as possible but not too simple, the file that comes with fail2ban roundcube-auth.conf seems to account for older installations of roundcube, something i don’t really need.

Now, here is a step by step manual to protect roundcube (Or phpmyadmin or ispconfig or what have you) from bruit force attacks and dictionary attacks.

1- Make sure fail2ban is installed
apt-get install fail2ban

2- add the following two configuration file to fail2ban programs directory (/etc/fail2ban/filter.d/)

1- roundcube.conf

# Fail2Ban configuration file for roundcube webmail
# Author: Fabian Wenk 
# $Revision$
# To have logging information available, it is necessary to adjusting
# the following option in config/ from Roundcube:
# $rcmail_config['debug_level'] = 1;	// not sure, probably not needed
# $rcmail_config['log_session'] = true;
# and point in the fail2ban jail config to the correct logfile,
# or change also the following config to log to syslog:
# $rcmail_config['log_driver'] = 'syslog';


# Option: failregex
# Notes.: regex to match the password failures messages in the logfile.
#	first line is for Cyrus IMAP (2.4.x)
#	second line is for Dovecot (2.1.x)
# Values: TEXT
#failregex = roundcube: IMAP Error: Login failed for .* from . AUTHENTICATE PLAIN: authentication failure in .*$
failregex = roundcube: IMAP Error: Login failed for .* from . AUTHENTICATE PLAIN: Authentication failed. in .*$

# Option:  ignoreregex
# Notes.:  regex to ignore. If this regex matches, the line is ignored.
# Values:  TEXT
ignoreregex =  

2- roundcube-repeat.conf, this rule inspects the fail2ban log file itself, and if there are repeated bans (repeated violations), imposes a bigger penalty

# roundcube configuration file


# Option:  failregex
# Notes.:  regex to match the password failures messages in the logfile. The
#          host must be matched by a group named "host". The tag "" can
#          be used for standard IP/hostname matching and is only an alias for
#          (?:::f{4,6}:)?(?P\S+)
# Values:  TEXT
failregex = \[roundcube\] Ban 

# Option:  ignoreregex
# Notes.:  regex to ignore. If this regex matches, the line is ignored.
# Values:  TEXT
ignoreregex =

The above is how fail2ban will identify failed logins, now in the /etc/fail2ban/jail.local we need to tell fail2ban 1- Where to look for this rule, 2- what file to look for the logs in !

So, to activate the above, we need to add some rules in /etc/fail2ban/jail.conf

enabled  = true
port     = http,https
filter   = roundcube
logpath  = /var/sys_ssl/rcmail/logs/errors
maxretry = 5
findtime = 600
bantime = 3600

enabled = true
port = http,https
filter = roundcube-repeat
logpath = /var/log/fail2ban.log
maxretry = 3
findtime = 21600
bantime = 86400

Now, to the testing, mind you, if you test, you will be blocked, depending on how you test, you might get blocked for a whole day, so keep that in mind

For those of you on a recent cpanel installation, you should probably know that iptables are disabled by default in favor of firewalld, fail2ban will update the rules, but the rules will not work šŸ˜‰

Keeping your mobile phone battery in good health

Phone manufacturers are leaning towards non removable batteries on higher end phones , the reason for that is that they can save space and use it to install a slightly larger battery making use of space previously lost in plastic holding the battery, with that , there seems to be interest in prolonging that battery’s life to avoid having to send it to a repair shop to crack it open and install a new one.

Their concerns are very understandable , sometimes repair shops cause some harm to your device , other times they install cheaper grade (or old stock) batteries that will need to be replaced again within months. So here is how we make sure we get the longest possible life out of a lithium battery. The first of the two sections below are for the average user, the second is for the more curious.

Side note: – An optional addition that can be very useful in your quest to keep your phone’s battery healthy (Adding convenience to the methods you will learn here) is a phone cover with a built in power bank, usually selling for $10 or so, or even a $5 mobile power bank, otherwise you will need to have a nearby charger handy at most times. So, that whenever we say connect a charger in this article, you could simply switch on the battery bank (Embedded in your phone cover)

Section 1 , how to use your phone to prolong the phone’s battery life.

1- – Charge your phone while it is switched off when possible.

This is probably not very important but here is he justification, when you recharge a battery, the charging circuit needs to measure the voltage of the battery to provide the right voltage , this is not possible in an accurate manner with the phone itself acting as an electric load , so the charging circuit will have to be cautious but not actually going through the last phase of the charge, while this will not deteriorate your battery’s life expectancy it will leave you with less power during the day which could sometimes mean going below 20% level of power by the end of the day, now that could do your battery some incremental damage (Internal corrosion) , to maintain your battery, you should avoid letting it go below 20% at all times.

2- Connect your charger/Battery bank while using the phone for power intensive tasks such as watching video or browsing the internet.

it is well known that lithium batteries suffer when discharged quickly, the exact reason is unknown , some claim it is related to ions getting trapped at higher rate, others believe it has to do with heating of either the phone’s CPU (close to the battery) and heating of the battery itself, we don’t really know why for 100%, all we know is that it is certainly bad for your battery but if your phone is plugged in during those activities , your phone will draw the current from the charging circuit instead of the battery, simply because the circuit will have to provide higher voltage than the battery, and from electricity 101 we know that your phone will draw electricity from the higher voltage source.

3- Recharge often. while your phone’s battery still has 40% – 60% of the charge , try to keep it above 15% at all times

– Older phones had nickle based batteries that forced full cycles, so it was best to fully charge your batteries, then drain them all the way down to zero, then recharge them again, people read those words in those manuals back in the nineties but no one actually told them that this is no longer the case , in fact that is terrible advice if ever applied to lithium batteries , most lithium batteries are happiest when they are charged between

40%-90% , the longer they stay at those levels , the longer they live

4 – Charge slow while you sleep, using a smaller capacity charger

phone manufacturers try to provide faster chargers to make your life easier, because no one likes to get tethered to a wall for long, but while you sleep , charging slow is in fact better for your battery, batteries have ratings for the maximum speed they accept a charge ( 0.5 c , 1 c , 1.5c etc.. ) but the rule thumb of the is that the higher the current the more exhausting it is for the battery’s health.

5- to conveniently use this advice without owning that battery bank case, i need a long charging cable right?? is there anything wrong with that??

well yes, and no , slow charging a battery is not a bad thing at all , but charging cables are usually thin for obvious reasons so the longer the cable the higher the resistance so you are actually.

A- wasting power that the wall adapter sent to the phone in form of heat generated by the cable

B- consuming your power adapter making it work harder for nothing

but it is generally okm, now if you are a perfectionist, a work around can be an electric extension cord between the charger and the wall socket, simply because the higher the voltage , the lower the amps, the thinner the needed wire, i will avoid getting into details now but that is one solution you can use

Also note that:

A mobile phone cover with built in battery bank will also help you avoid wear on the charging connector.

These connectors on your phone are rated for a finite number of plug/unplug cycles, what amplifies that wear on the connector and wire is the fact that i am actually recommending that you charge the phone while you use it in certain circumstances now while this is good for your battery it is certainly bad for the socket on your phone, the aforementioned cover will keep your phone chargingĀ  socket from wearing out.

right now you are probably thinking that I’m affiliated with some sort of manufacturer , well , I’m not , and that is why i am forced not to recommend one any phone cover with a power bank built in , but please do read customer reviews before you buy one. Some of them have very cheap quality bateries inside.

Partition 2 does not start on physical sector boundary

Here is the lowdown, fdisk does not assume you have advanced format probably if your disk has a logical of 512 and a physical of 4K.

So it will likely print

Partition x does not start on physical sector boundary

fdisk is wrong, your partition may or may not be aligned

In reality, just by running fdisk with the new alignment should tell you if it is really miss aligned, or fdisk is miscalculating


fdisk -b 4096 -u /dev/sda

Now try and print, if you still see that message, then it is miss aligned, otherwise you are fine

Showing disks attached on a linux computer

The application that will probably be available on every system would be fdisk, so i will start with that

fdisk -l

But that is not my favorite, the one i use (Because i have disks of same size so i need more information) is

lshw -class disk

But i still need to know the partitions so fdisk -l will be necessary with that too

There is a third option,

hwinfo --disk

And, because sometimes i want to see parititons too


Will do the trick

flogging a dead kindle (BACK TO LIFE !)

Kindle Keyboard
Kindle Keyboard working again

My kindle was displaying a message saying

Battery Empty

Connect your kindle to a power source and charge it until this screen disappears. This may take up to 30 Minutes

If you continue to see this screen after charging, you will need to reset your Kindle. Unplug it from the power source, then slide and hold the power switch for 15 seconds.

In short, both did not work, Once plugged into a charger, The orange light will come up for a few seconds, then it will disappear, my charger LED will also turn off meaning no power is being drawn, resetting did not resolve it either as it seems there is absolutely no power in the battery, considering that i have left it for months without use or charging.

So, the solution seemed to be heating it up a bit against an electric fan heater (Few seconds, don’t make the kindle hot), then plugging it into a charger kept the orange light on, the orange light flickered for a few seconds after plugging it in (Obviously not a “by deign” kind of flickering).

Also worth mentioning that one of the chargers works better than the other, after the heating, one of the chargers (Larger capacity) seems to hold the orange charging light steady, while the smaller one seems to fail within a few seconds of plugging it in (orange light goes out)

Now, it seems to be charging, the battery empty page refreshed, but still gave a battery empty page, then a few seconds later, what do you know, that battery empty screen disappeared and the kindle initiated a boot sequence (The normal screen that appears when you start the kindle with a progress bar) (If this does not happen after 30 minutes of orange light lit up, You might want to consider resetting it like the kindle says).

This is one of the very old kindles, It dates back to many years ago. In the footer of the menu, it says kindle 3.3, on the back it says (Kindle model number D00901), But i am not really planning to invest time finding out what this kindle is called, it is the one with the keyboard

Source of the problem, a theory, Lithium batteries have a cutoff charge, meaning, devices leave some power in a battery (And consider it empty, switching themselves off before a complete drain) because if the voltage goes below that threshold, it can be dangerous to recharge.

Heating probably registered some voltage on the battery convincing the kindle to charge it.

The 3-4 seconds of mild flickering is still a mystery though.

Final note: Once the kindle booted, both chargers seemed to work just fine.

DBMAIL commands

First thing first, using the manual, your commands will go in dry run mode, no hints are given on why needed changes are counted but not executed, this is because you have to rn the command with the y switch to do the changes, here are a few ones you will use often

dbmail-util -dy – set delete status on deleted mail (deleted by IMAP or POP)
dbmail-util -py – delete messages with delete status

dbmail-util -by – rebuild the caches

Without the Y, no changes will be made to the database

Wake on LAN with linux

My always on Linux machine is a dell FX 160, very low power consumption, should work as my VPN, asterisk server, and wake up other computers when i need them, the device itself is multi homed, So i basically need it to wake up other devices on one of the networks

The commands you need for this to work are as follows

etherwake -i eth1 xx:xx:D2:B2:30:C9 (My laptop)

eth1 is the network connected to my mini linux server that is connected to the target network.

Thats all there is to it, in addition to enabeling wake on lan in your BIOS

Windows 10 slow shutdown on SSD (Solved)

SSDs are the best thing that happened to computer boot time (and many other things) since the invention of the abacus

But for some reason, booting up is faster than shutting down, much faster, Shut downs are taking a long time (Or reboots)

So let me see what i can do about this

1- Windows ClearPageFileAtShutdown is something that happens before shut down, and is my first guess to why this is happening
So let us set the following key to zero (0) and see if this speeds up shutdown time.

HKEY_LOCAL_MACHINE\CurrentControlSet\Control\SessionManager\Memory Management then ClearPageFileAtShutdown set to (0)

This session should shut down slowly, the next time you boot, shutdown will be much faster.

The other thing that i am thinking is relevant is changing the location of the indexing service index files to my spinning disk, this is because the spinning disk has thousands of files, and i would like to keep my SSD fast for certain other applications.

CP overwrite files in destination

Although the copy program cp in Linux overwrites without prompting, in practice, it does not, the reason behind that is that the command is aliased with the (cp -i), you can check that by using the alias command

So there are 2 solutions to this to make cp overwrite

The first would be to unalias, while the second would be to execute the command directly with


Or you can use the full path to the alias command like


I personally use

\cp this that

Aligning your Samsung 840 EVO – Slow disk problem

This probably applies to both 840 evo and 850 evo, but not the EVO 840 PRO and the 850 evo pro because the pro are not TLC

All over the internet, people are saying that solid state drives don’t need to be aligned because they will scramble the used flash cells anyway for wear leveling.

This is absolutely NOT TRUE, although wear leveling does work that way (in a simplified way), the mapping algorithm that levels the writes maps blocks to other blocks.

So here is how it works, let us assume there was no wear leveling, when the partition is not properly aligned to a starting offset which is a multiple of the eras block size, writes and erase operations that should require the erasing of one block could end up erasing and writing to two blocks, now the block is a hardware restriction, so when the wear leveling algorithm selects a new location, the problem of sing two cells instead of one is still valid.

Don’t take my word for it, mess up the alignment of one of your partitions, then examine reads and writes of 512 or 4K, both will be much slower.

Now, what you need to do is to align the file system to block size

Because this disk has a 1.5M erase block 1536 KiB and to be sure we want it to also align with 2048 KiB (Just in case the erase block is not the whole story), you can set the sector alignment value to 12288 (6144 KiB), which is a multiple of 1536 KiB and 2048 KiB.

So, in LINUX, even though it is usually correctly aligned by the partitioning software (And in windows it is already done for you and if not it can be done by samsung’s magician software), you can check the current alignment with.

fdisk -l /dev/sdb

For your own math, the EBS (Erase block size) on those drives is 1.5MBs

So basically, 12288 is 3*4k, the three comes from the fact that it is a three level cell (TLC)