Author: simkin@simkin.org

  • Son of Huck!

    After having my Defender 110 stolen and the insurance paying out what I paid for it, I realised I really should have updated my policy as the value of 200Tdi Defenders started to rise. So with £5,500 in my pocket and some savings in hand, I upgraded to a TD5 but downgraded to a shorter wheelbase.

    It has a little bit of “Kangarooing” under high revs, no anti-rollbars, suspension needs a revamp, middle jump seat instead of a cubbybox, chassi is looking like it might need renewing inside three-five years, the wrong bonnet (but I’ll keep that), a leaking steering box (but Huck did too), winch bumper but no winch, only a single battery, pathetic headlights.. etc.. etc..

    Should keep me amused for a while.

  • Huck stolen!


    My faithful Land Rover Defender was stolen on Tuesday 11th December 2018. I am gutted. I’ve owned the car for about six years and spent a lot of time, effort and money on keeping it running as well as upgrading things on it. Somebody out there decided they would just take it because they could. For them it was a pile of money parked on the road which they felt entitled to break into and drive away. To me it was much much more.
    I am sure the insurance will eventually pay some money out after the next few weeks of them investigating it. I expect I’ll get less than I paid for it and not enough to be able to replace it with a similar vehicle. I will also never again see the personal possessions in the vehicle. Some I bought, some were gifts. I had a few tools that I inherited from my deceased father. Maybe a few pounds in cash value but a fortune to me sentimentally. I used to take pride in the fact I was using my Dad’s tools to keep ‘Huck’ on the road.
    None of this will worry the people that stole my car. They will strip it down, burn it out or ship it abroad for sale and I will probably never see it again.
    If you do see a white Land Rover Defender, K451 FYN please call the police on 999 or post to Landywatch.

  • Blocking Spammers by IP address in Postfix

    I’ve had a few unwelcome visitors to my mail server and for the most part, the filters I have in place are keeping them at bay. However, there are a few determined bots that whilst not being able to bypass my filters, they do appear too often in my logs to let me just ignore them. They deserve my very specific attention. So, herein the guide to blocking senders by IP address in Postfix:
    Create your blacklist in a text file called /etc/postfix/client_checks in the following format:

    39.109.123.121     REJECT Your IP is blacklisted
    52.175.18.205      REJECT Your IP is blacklisted
    112.102.225.21     REJECT Your IP is blacklisted
    
    

    Add this check to /etc/postfix/main.cf:

    smtpd_recipient_restrictions =
     check_client_access cidr:/etc/postfix/client_checks,
     ...

    Convert the file to a hashmap and reload Postfix:

    sudo /usr/sbin/postmap client_checks
    sudo /usr/sbin/postfix reload
    

    Notes:
    * Check you /var/log/maillog to see if there are any errors caused by your changes
    * You can also use “OK” lines rather than “REJECT <text>” to permit hosts that are failing checks further down because for example, their sysadmin doesn’t know how to reverse DNS
    * Further reading: http://www.postfix.org/cidr_table.5.html
    *We probably don’t need to generate a hashmap when using “cidr:/” but it is an old habit I can’t break

  • Transfer Windows 10 to a New Hard Disk without additional software

    It can be done!
    Things you will need:

    • Beg, borrow or steal an external Hard Drive that you can store a backup of your current drive
    • A blank CD (yes! CD-R is fine) or USB key

    Backup:

    1. Connect the external USB Hard Drive.
    2. Hit the Windows Key and type “System Image” choose “Backup Settings” when it suggest it
    3. Under “Looking for an Older Backup?” click “Go to Backup and Restore (Windows 7)”
    4. In the left-hand menu choose “Create a system image”
    5. Choose the location of your external USB drive and let the image be created. It will take a while….
    6. When it completes it offers to create a Windows Repair disk. Do it! (use the CD-Rom or USB Key)


    Shutdown

    1. Unplug your old hard drive
    2. Plug in your new one
    3. Boot from the Repair disk
    4. Under Advanced, choose Restore from System Image. It will take a while….
    5. Remove the External drive, Eject the Windows Repair disk/key

    Reboot!
    Note: If you need to resize your hard disk partition, you might need some software for that depending on your disk type. Rather than buy something look up “Ultimate Boot CD” and use one of the free tools on that.
     
    Note:
    Sometimes the recovery disk gets you to a screen that reads “Choose your keyboard layout” and doesn’t respond to you beating the keyboard. Your best bet is to try a different boot method. Go here https://www.microsoft.com/en-gb/software-download/windows10 and download the media creator to make a USB stick to install Windows on another computer. When you get to the screen with the language selection, choose the REPAIR link and follow it from there.
     

  • Is your PC part of a global botnet?

    Now you can find out thanks to Kaspersky Labs and this neat little tool: https://checkip.kaspersky.com/

  • Trackbacks and Pings in WordPress

    If  you are getting lots of random and unexpected entries in your web logs like this one:

    37.29.48.76 - - [27/May/2017:13:04:13 +0000] "POST https://simkin.org/wordpress/wp-trackback.php?p=206 HTTP/1.1" 400 302

    then you are being targeted by spammers looking to fill your blog with spam comments or to generate response emails to random endpoints, which in turn keeps your mail server busy.
    Trackbacks are useful in theory but I find they generally just get abused and turn them off. I had overlooked it on my current WordPress instance but this post is the most thorough set of instructions to remedy it…
    http://www.wpbeginner.com/wp-tutorials/how-to-disable-trackbacks-and-pings-on-existing-wordpress-posts/

  • Apache Security

    I have recently been the unfortunate recipient of some website hacking leading to a minor bit of spam injection into my mail server. Nothing too serious and due mainly to an old version of Centos and some WordPress code that could have been constructed a little bit better, but anyway. So what do you look for when checking your webserver and how do you keep it a little bit more secure?
    In my case, I had a few random .php pages inserted and my investigation spurned me on to take the basic steps I should have done in the first place. Some of these were already correct but no harm in covering them:

    1. Set your apache instance to NOT run as root and set your file permissions to read-only to all places that need access by the server. Things to look for:
      • in /etc/https/conf/httpd.conf, make sure the user and group lines are a user like “www-data” or “apache”
    2. Keep an eye on /var/log/<websitename>-access_log for odd stuff going on
      • I have a php page on my webserver that looks for post messages for example. Any that I don’t like, I block the client site. To block people from your website, include this in your vhost:
      • Order deny,allow
      • deny from 1.2.3.4/24
      • allow from all
    3. If you run phpMyAdmin, ensure you ONLY allow hosts you recognise
    4. Install mod_security (read: https://www.cyberciti.biz/faq/rhel-fedora-centos-httpd-mod_security-configuration/)
    5. Edit your .htaccess file to prevent http1.0 POSTing:
      • # require HTTP 1.1 for POST
        <IfModule mod_rewrite.c>
        	RewriteCond %{THE_REQUEST} ^POST(.*)HTTP/(0\.9|1\.0)$ [NC]
        	RewriteRule .* - [F,L]
        </IfModule>
    6. Setup a PHP file on your website to allow you to quickly review what is going on from anywhere. Mine does this for example:

     

     <?php
    $badtext = array("<",">");
    $goodtext = array ("{","}");
    $output = shell_exec('ls -la webcam.jpg');
    echo "<pre>$output</pre>";
    $output = shell_exec('date');
    echo "Page Refreshed:<pre>$output</pre>";
    echo "Who has been trying to hack simkin.org...<br>";
    $simkinhackers = shell_exec('tail -n60 /var/log/simkin.org-access_log | grep "POST"
    ');
    foreach(preg_split("/((\r?\n)|(\r\n?))/", $simkinhackers) as $line){
     //output the first bit of each line with the ip address
     $pos = strpos($line, "-")-1;
     //now the rest of the line
     $ip = substr($line, 0,$pos);
     if (strlen($ip)>1) {
     echo "<br /><a href='chkIP.php?item=".$ip."'>".$ip."</a>";
     echo "<a href='https://www.abuseipdb.com/check/".$ip."'>.</a>";
     echo substr($line,$pos,strlen($line)-$pos);
     }
    }
    $simkinhackers2 = shell_exec('tail -n60 /var/log/simkin.org-access_log | grep "USER"');
    foreach(preg_split("/((\r?\n)|(\r\n?))/", $simkinhackers2) as $line){
     //output the first bit of each line with the ip address
     $pos = strpos($line, "-")-1;
     //now the rest of the line
     $ip = substr($line, 0,$pos);
     if (strlen($ip)>1) {
     echo "<br /><a href='chkIP.php?item=".$ip."'>".$ip."</a>";
     echo "<a href='https://www.abuseipdb.com/check/".$ip."'>.</a>";
     echo substr($line,$pos,strlen($line)-$pos);
     }
    }
    $simkinhacker3 = shell_exec('tail -n60 /var/log/simkin.org-access_log | grep "action=upload"');
    foreach(preg_split("/((\r?\n)|(\r\n?))/", $simkinhackers3) as $line){
     //output the first bit of each line with the ip address
     $pos = strpos($line, "-")-1;
     //now the rest of the line
     $ip = substr($line, 0,$pos);
     if (strlen($ip)>1) {
     echo "<br /><a href='chkIP.php?item=".$ip."'>".$ip."</a>";
     echo "<a href='https://www.abuseipdb.com/check/".$ip."'>.</a>";
     echo substr($line,$pos,strlen($line)-$pos);
     }
    }
    $simkinhackers4 = shell_exec('tail -n200 /var/log/simkin.org-access_log | grep "lostpassword"');
    foreach(preg_split("/((\r?\n)|(\r\n?))/", $simkinhackers4) as $line){
     //output the first bit of each line with the ip address
     $pos = strpos($line, "-")-1;
     //now the rest of the line
     $ip = substr($line, 0,$pos);
     if (strlen($ip)>1) {
     echo "<br /><a href='chkIP.php?item=".$ip."'>".$ip."</a>";
     echo "<a href='https://www.abuseipdb.com/check/".$ip."'>.</a>";
     echo substr($line,$pos,strlen($line)-$pos);
     }
    }
    # Grab the IP addresses to a logfile
     $ip1 = shell_exec('tail -n60 /var/log/simkin.org-access_log | grep "POST" | egrep -o "([0-9]{1,3}\.){3}[0-9]{1,3}"');
     $ip2 = shell_exec('tail -n60 /var/log/simkin.org-access_log | grep "USER" | egrep -o "([0-9]{1,3}\.){3}[0-9]{1,3}"');
     $ip3 = shell_exec('tail -n200 /var/log/simkin.org-access_log | grep "lostpassword" | egrep -o "([0-9]{1,3}\.){3}[0-9]{1,3}"');
     $textstring = $ip1.$ip2.$ip3;
     file_put_contents('~/badpeople.log',$textstring , LOCK_EX);
     $nul = shell_exec("cat ~/badpeople.log | awk '!seen[$0]++' > ~/badpeople.txt");
     $handle = fopen("~/badpeople.txt", "r");
     if ($handle) {
     while (($line = fgets($handle)) !== false) {
     // process the line read.
     echo "<br /><a href='https://www.whois.com/whois/".$line."' target='new'>".$line."</a>";
     }
     fclose($handle);
     } else {
     // error opening the file.
     }
     ?>
    1. Whitelist your website to only allow POSTing to pages you expect to see POSTS (see: https://perishablepress.com/protect-post-requests/)
    2. Keep a backup
    3. Update everything regularly with sudo apt-get update or yum update
  • iPhone not appearing in iTunes

    * Open Device Manager
    * Right-click the Apple Mobile Device and choose “Update Driver Software”
    * Select “Browse my computer for driver software”
    * Select “Let me pick from a list of device drivers on my computer.”
    * Click Have Disk.
    * Navigate to C:\Program Files\Common Files\Apple\Mobile Device Support\Drivers.
    * Next and then Finish. Windows will install the driver
    iPhone should burble an connect if it is already plugged in and iTunes is open.

  • Windows 10 "Attempted Switch from DPC" Blue screen caused by Acronis Scanman

    I have spent some time diagnosing a sick PC which intermittent BSOD (Blue Screen of Death) and decided against the recommended “nuke from orbit” approach to it, instead deciding stubbornly that the machine was in fact recoverable with all user settings and files intact.
    I updated the latest BIOS and AMD chipset drivers, even though Asus had long since given up keeping the driver library refreshed for this old motherboard.

    That didn’t work. So next thing was to install something to help diagnose the BSOD events. Event Viewer isn’t a lot of use, but Windows tends to drop “dump” files when it crashes and if you know what you are looking at, they can help identify the culprit. If not, use a tool that makes it easier. I recommend “WhoCrashed” for this sort of thing:

    In my case, the culprit seemed to be SCANMAN.SYS, a driver by Acronis which does a great job of shifting disk chunks around for replication or backup operations. In my case though, those tools hand long since been removed. The Windows 10 Anniversary update had somehow made this dormant file into some kind of psychopath. It needed to go. But removing it is not just a case of hitting delete. Do two things first (just in case something goes wrong and you need to roll-back or boot from USB and run a startup-repair:

    • Create a System Restore point
    • Create a USB Recovery Drive

    Now for the messy bit (the long-hand version is here: https://kb.acronis.com/content/1620).

    • Go to the Start, Run Type “regedit” and click OK. This will open the Registry Editor
    • Navigate to: HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Class\{4D36E967-E325 -11CE-BFC1-08002BE10318}
    • In the “UpperFilters” key, remove any reference to “snapman” but leave any other values in place. For example “cat snapman dog” becomes “cat dog”.
    • If it exists, in the “Lowerfilters” key, do the same.
    • Navigate to: HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Class\{71A27CDD-812A -11D0-BEC7-08002BE2092F}
    • In the “UpperFilters” key, remove any reference to “snapman” but leave any other values in place. For example “cat snapman dog” becomes “cat dog”.
    • If it exists, in the “Lowerfilters” key, do the same.
    • Navigate to: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\snapman
    • Create a new REG_DWORD value, name it DeleteFlag and set it with a value of 1
    • Edit or create a REG_DWORD value named Start and set it with a value of 4
    • Reboot
    • After the reboot, navigate to this folder: C:\windows\system32\drivers and rename snapman.sys to snapman.old. If it isn’t there, the reboot removed it already.
      Reboot again and then create a new Restore Point.
      If at any point the PC fails to load due to “inaccessible boot device”, simply plug in the USB recovery drive you created earlier and under the advanced menu, choose “Repair Startup. That will tidy up the registry entries and make it work again.
      At this point I recommend running something like Wise Registry Cleaner to tidy things up.
      You should be good now. 🙂
  • Home Automation at a bargain price

    ad560dac-3c75-42c9-8236-5dcebb79296dI discovered these little “Orvibo S20” sockets that let you turn sockets on and off using your iphone. Very neat.
    You can also do this over the Internet. But I’m not entirely convinced that the third-party proxy is secure enough for my level of internet security paranoia. I mean, I am sure it is fine but I only paid them a one-off fee under £20, so their motivation to run a highly secure proxy is going to eventually wane a little. So I need another solution.
    Fire-up a Raspberry PI and have a play with this project on Github. You’ll soon have a webpage on your PI that lets you turn sockets on and off. Now it is in your control, putting it behind a VPN tunnel or SSH session is a possibility.
    Now go look at what the more expensive proprietary home automation systems cost and decide if £20 and a few hours of your time makes sense…