Apache – prevent SQLite DB from download

If you are using SQLite for your website as backend database then it is important to prevent others from downloading the entire database, since SQLite is a file then it can be solved by denying access to the file from the web by this .htaccess rule

RewriteEngine On
RewriteCond %{REQUEST_URI} (.*).db [NC]
RewriteRule ^(.*)$ 404.html [R=404,L]

The rule will prevent access to all files with .db in the name, that will prevent download of files like blog.db mydatabase.db etc.

In my example it will redirect to a 404.html page

Your php script is running inside the server and will still have access to your database files as long as it has the correct unix fileaccess

How to change 15pin to 14pin VGA

If you have an old IBM PC with VGA and it’s only 1 pin where the normal is 15pin then don’t panic, it’s possible to change that by removing one pin and then it can connect to 15 pin monitor, you just need to remove it in one end and you have a 14pin to 15pin adapter cable 😉

Here is my modified 15 pin cable, just changed it in one end and it worked wih my 15 pin LCD monitor

Seems like one of the purposes for the one pin is that newer vga monitor can report it’s resolution back to the computer so you need to set that manually.

How to copy .img files to floppy with DD

If you are into retro computing and need to copy one of the old floppy .img disks to a diskette then it can be done with dd for unix/linux or by using the windows port of dd

My son learning to code Power Basic for DOS and switching floppies 😉

In my case i had 2 computeres with a floppy drive, one was a Windows XP machine and the other was a much older DOS computer without USB or network and i need to test FreeDOS and MS DOS 6.2 but i only had files like disk1.img downloaded from the internet and blank 1.44 floppy disks.

In my first attempt i tried to use a Windows program called winimage but it was not able to run on the old Windows XP, maybe it needed a servicepack or somthing else, so the fastest way was to find a simpler and faster solution and dd came in to my rescue.

here is How to copy a disk.img to floppy with dd

Unix/Linux

dd if=disk1.img of=/dev/fd0

Windows (DOS or CMD Console)

dd if=disk1.img of=\\?\Device\Floppy0

It can be downloaded at http://www.chrysocome.net/download

OR from my server https://www.pvangsgaard.com/download/dd-windows/

Prevent WordPress Brute-force attacks with fail2ban

Introduction

If you run wordpress on a Raspberry Pi then the chances are very high that you get attacked with many attempts and failed logins on you wp-login.php file.

In my case all these attempt showed up in my websites statistics as uniq ip’s that have had many tousands hits on my site…..it’s not only a security problem, but it also have a small impact on performance of your site, i was lucky my Pi 3 didn’t complain and was fast enough 😉

You can use the filters and jails in this post on other linux distributions, but the fail2ban and log files may be in a different place, i have made this to work for the Pi 3 with Rasperian (Debian)

Setting up fail2ban jail and filter rules

I assume that you allready have installed fail2ban

Open the jail configuration

sudo vi /etc/fail2ban/jail.d/defaults-debian.conf

Put this section in the file and save

[wordpress]
enabled = true
port = http,https
filter = wordpress
action = iptables-multiport[name=wordpress, port="http,https", protocol=tcp]
logpath = /var/log/apache2/*.log
maxretry = 30
findtime = 10800 ; 3 hours
bantime = 86400 ; 1 day

Make a filter file for wordpress

sudo vi /etc/fail2ban/filter.d/wordpress.conf

Make this section and save file.

[Definition]
failregex = ^<HOST> .* "POST .*wp-login.php
            ^<HOST> .* "POST .*xmlrpc.php
ignoreregex =

Restart fail2ban

sudo systemctl restart fail2ban