RSSAmplifier

Blog

Philipp's Tech Blog

Hi, my name is Philipp C. Heckel and this is my tech blog.

blog.heckel.ioRSS feed ↗71 posts

Latest posts

Lossless MySQL semi-sync replication and automated failover

MySQL is a really mature technology. It’s been around for a quarter of a century and it’s one of the most popular DBMS in the world. As such, as an engineer, one expects basic features such as replication and failover to be fleshed out, stable and ideally even easy to set up. And while MySQL [ ]

elastictl: Import, export, re-shard and performance-test Elasticsearch indices

For my work, I work a lot with Elasticsearch. Elasticsearch is pretty famous by now, so I doubt that it needs an introduction. But if you happen to not know what it is: it s a document store with unique search capabilities, and incredible scalability. Despite its incredible features though, it has its rough edges. And [ ]

Snippet 0x0F: Recursive search/replace tool “re”

Two and a half years ago, I wrote my first Go program. I wanted to learn another language, and Go looked like a ton of fun: straight forward, easy to learn, and a static binary with no runtime shenanigans. I picked a project and I started hacking. Looking back, the code I wrote is a [ ]

Go: Calculating public key hashes for public key pinning in curl

Something occurred to me the other day. This is my blog, and that means I can write about whatever I want. Now you may think that s totally obvious, but it s not. For the longest time I wouldn t blog about anything that I didn t deem blog-worthy. Small things, like this is a cool function I found [ ]

Reliably rebooting Ubuntu using watchdogs

Rebooting Ubuntu is hard. I don’t really know why, but in my twelve years as an Ubuntu user, I’ve encountered countless “stuck at reboot” scenarios. Somehow, typing reboot always comes with that extra special feeling of uncertainty and the thrill of danger Will it come back? Where will it get stuck this time? If [ ]

Providing remote access to devices via SSH tunnels

At my work, the backup appliances are typically physically located inside the LAN of our end users much like other appliances such as routers, NAS devices or switches. Under normal circumstances that means that they are behind a NAT and are not reachable from the public Internet without a VPN or other tunneling mechanisms. [ ]

Image based upgrades: Upgrading software and OS of 80k servers every two weeks

Anyone that’s ever managed a few dozen or hundreds of physical servers knows how hard it can become to keep all of them up-to-date with security updates, or in general to keep them in sync with their configuration and state. Sysadmins typically solve this problem with Puppet, or Salt or by putting applications in a [ ]

Deduplicating NTFS file systems (fsdup)

At my work, we store hundreds of thousands of block-level backups for our customers. Since our customer base is mostly Windows focused, most of these backups are copies of NTFS file systems. As of today, we re not performing any data deduplication on these backups, which is pretty crazy considering that how well you d think a [ ]

Snippet 0x0E: Booting image files and ISOs with KVM/QEMU (EFI and BIOS)

For my job, I work with file systems and image files a lot: Every day, we mess with Grub, the partition tables (MBR/GPT), EFI and BIOS systems, etc. So pretty much every day, I need to boot some image file or investigate why some image didn t boot. This (super duper) short post shows how to [ ]

Using Let’s Encrypt for internal servers

Let s Encrypt is a revolutionary new certificate authority that provides free certificates in a completely automated process. These certificates are issued via the ACME protocol. Over the last 2 years or so, the Internet has widely adopted Let s Encrypt over 50% of the web s SSL/TLS certificates are now issued by Let s Encrypt. But while [ ]

USB disk causes blinking cursor at boot; how to “fix” the MBR bootstrap code

Have you ever rebooted your computer only to see a black screen with a blinking cursor? If you have a USB drive attached, chances are the blinking cursor is caused by invalid bootstrap code in the Master Boot Record (MBR) on that drive which has caused the normal boot execution to stop without returning control [ ]

Creating a BIOS/GPT and UEFI/GPT Grub-bootable Linux system

Good old Master Boot Record (MBR) unfortunately cannot address anything beyond 2TB, so partitioning large disks and making them bootable is impossible using MBR. The GUID Partition Table (GPT) solves this problem: It supports disks up to 16EB. However, installing grub does not work without a special BIOS boot partition. If you also want to [ ]

How-To: Using ZFS Encryption at Rest in OpenZFS (ZFS on Linux, ZFS on FreeBSD, …)

An upcoming feature of OpenZFS (and ZFS on Linux, ZFS on FreeBSD, ) is At-Rest Encryption, a feature that allows you to securely encrypt your ZFS file systems and volumes without having to provide an extra layer of devmappers and such. To give you a brief overview of what the feature can do, I thought [ ]

zfsu: ZFS utils for offsite backup, retention and maintaining a slow mirror

My laptop runs ZFS as its root file system (see this blog post) meaning that I can snapshot my root file system and I can send it to another machine as a backup very easily. Unfortunately, while ZFS provides the raw functionality, there is no great tool to manage offsite backups and retention. To [ ]

How-To: Move your existing Linux install to ZFS on Root

Ever since I joined my new company two years ago, ZFS has been part of my work every day. And every day, I am amazed how great it is. So naturally, I wanted to move my existing Linux Mint 18 installation to boot off of ZFS. Why, you may wonder? Well that s easy. Because now [ ]

How-To: Your own dynamic DNS server (with PowerDNS & a MySQL backend)

I was using dyndns.org and no-ip.com for a long time, and because I m too cheap to buy the premium version for a simple service like this, I finally decided to set up my own dynamic DNS server for my various systems. This is a short tutorial describing how I did it. It s really not rocket [ ]

How-To: PHP based JSON-RPC API, with authentication, validation and logging

At my work, we use JSON-RPC based APIs very heavily, in particular with our PHP JSON-RPC library php-json-rpc. While JSON-RPC is not as wide spread as REST, it fits our needs quite nicely. In particular, it is protocol independent and can be used over HTTP, SSH or as local CLI. With our library and its [ ]

Snippet 0x0D: Let’s Encrypt – 5 min guide to set up cronjob based certificate renewal

Let s Encrypt was officially released to the open public today. That means the Internet can finally get free, trusted SSL/TLS certificates. This quick guide shows how to set up Let s Encrypt with auto-renewal through a cronjob using the simp_le client, an alternative client developed by one of the same authors who develop the official [ ]

How-To: Create a Debian package and a Debian repository

Debian packages and repositories are everywhere, yet many people don t understand that creating them is actually pretty easy. While there are dozens of tutorials out there, none of them seemed to really show a good step-by-step. This is a quick tutorial on how to create a Debian package from scratch, and how to create a [ ]

Snippet 0x0C: Load multiple composer.json files at runtime

Remember the times when we copied PHP libraries into our project folder, or we copy and pasted code from some random site into our project? Those times are over. Composer and Packagist are the modern way to manage PHP dependencies. They are great. Almost as good as The Maven repos and their build tools in [ ]

OpenSSH ‘AuthorizedKeysCommand’ with ‘fingerprint’ argument (Patch for OpenSSH 6.6p1)

Many of us developers or system administrators use OpenSSH s public key authentication (aka password-less login) on a daily basis. The mechanism works based on public key cryptography: By adding a RSA/DSA public key to the authorized_keys file, the user with the matching private key can login without a password. The mechanism works great for a [ ]

Snippet 0x0B: Bash completion with sub-commands and dynamic options

Every system administrator, most programmers and countless of command line surfing Linux/Mac users use it every day without thinking twice. Hitting the tab key twice, [TAB][TAB], has become the most common thing in the world. Bash completion is the magic behind the tab key. It s easy to use, but it s a pain to write. This [ ]

Snippet 0x0A: Cryptography DOs and DON’Ts

This tiny post is meant as a loose collection of DOs and DON Ts I ve come across when I implemented the cryptography concept for Syncany, my open source file sync software. I m not a cryptography expert, so take my advice with caution and correct me if you know more than I do. Cryptography DOs and [ ]

Circumvent Internet blockages/filters/censorship with socksproxy and netcat

These days, ISPs are often forced to block the access to certain sites, because their government considers these sites dangerous and/or illegal. While one could certainly discuss the usefulness of such measures in great detail, this tiny post focuses on the more interesting subject of how to circumvent these blockages. It s not a lenghty post, [ ]

Snippet 0x09: Reading a ZIP/JAR file with PHP (here: a JAR manifest)

For my open source file sync software Syncany, I have integrated the automatic plugin build process (we provide plugin repository and an easy plugin API to download plugins) with an upload to the Syncany API server. Plugins (JAR files) are uploaded by Travis (example: Samba plugin) to the Syncany server. To serve meta data on [ ]

Snippet 0x08: HTTP Basic Auth for secure WebSocket connections (with Undertow)

For my open source file sync software Syncany, I use the embedded web server and web socket server Undertow to provide a websocket and REST based interface by the Syncany daemon. Syncany clients (such as the GUI, or potentially a web interface) connect to this daemon, send requests and receive asynchronous events. Syncany s GUI client [ ]

Snippet 0x07: Restart Docky from a cronjob (when it crashed)

I recently updated from Linux Mint 16 Petra to Linux Mint 17 Qiana. Everything went smoothly, except for my dock Docky. For some reason, Docky decides to crash every once in a while with some error message. Instead of fixing this error or reporting it, I decided to find the easy way out and simple [ ]

Snippet 0x06: Disable SSLv3 in Firefox to protect against POODLE attack

The recent POODLE attack (Padding Oracle On Downgraded Legacy Encryption) exploits a vulnerability of an older version of SSL (SSLv3) by performing a padding oracle attack and thereby allowing a man-in-the-middle scenario. To be vulnerable, both client (browser) and server have to support SSLv3. If either one does not support or has disabled the [ ]

Snippet 0x05: Windows .bat: Checking if process is running by PID file

Batch (.bat) files are an MS-DOS legacy technology and I don t know a single person who loves writing them and yet, to this day, many people have to do it. In order to run Java programs, start daemons or check if a process is running, batch files have to be used. For my open [ ]

Snippet 0x04: Run .sql-scripts from Java (on HSQLDB, Derby, MySQL, etc.)

Java is sometimes harder than it should be. Oftentimes, very easy things are made hard for no apparent reason. Running SQL scripts (.sql) from inside Java is one of those cases. I really expected this to be easy. And it should be, right? Simply take your JDBC connection and do connection.executeScript() or something. After all, [ ]

Snippet 0x03: Recursively watch folders on Java (using the Java 7 WatchService)

The new Java 7 WatchService provides a mechanism to easily monitor a single folder for file system events. Java uses the underlying OS mechanisms to realize that (inotifiy on Linux, and ReadDirectoryChanges* on Windows). What the WatchService cannot do, however, is monitor a folder recursively meaning monitoring all sub-folders and register new folders if [ ]

Snippet 0x02: Getting the Java process PID and managing PID files (Linux/Windows)

To the best of my knowledge, Java doesn t offer a good way to get the OS-dependent PID of its own process. Sure, there are libraries to do that but do you really want to add a heavy library for this simple task? Well I didn t. Syncany already has so many dependencies, I don t want [ ]

Snippet 0x01: Undertow, an embeddable Java HTTP / WebSocket / REST server

Undertow is a lightweight HTTP and WebSocket server for Java. It s super simple to set up and works with Java SE. I tried using it in my open source file sync tool Syncany and it works beautifully. Content 1. Undertow is awesome! 2. Undertow speaks WebSocket! 3. Delivering static resources 4. Links A. About this [ ]

The magic of Gradle: create Windows installers, Debian packages, manage a PPA, and optional sub-projects

Gradle is great build tool. Compared to Ant or Maven, it s so much easier to use and write proper code for it it s unbelievable at times. A little while ago, I switched from an ugly Ant/Maven installation to Gradle with my open source project Syncany. Ever since then, I am simply amazed about what [ ]

CipherInputStream for AEAD modes is insecure in JDK7 (GCM, EAX, etc.)

If you have a little bit of cryptography know-how, you ve heard of GCM, EAX and other Authenticated Encryption with Associated Data (AEAD) block cipher modes of operation. If you haven t, AEAD modes not only encrypt data, but also authenticate it so that the ciphertext cannot be tampered without detection. In addition to that, AEAD modes [ ]

Deep into the code of Syncany – command line client, application flow and data model (part 2)

I recently published a blog post about my open source file sync project Syncany. I explained the main idea of the project and also went into some of the details about where the development is headed. The post was the first of a series I am planning to write showing what the project is [ ]

Syncany explained: idea, progress, development and future (part 1)

Many many moons ago, I started Syncany, a small open source file synchronization project that allows users to backup and share certain folders of their workstations using any kind of storage, e.g. FTP, Amazon S3 or Google Storage. At the time of the initial annoucement of the project (May 2011), there was a big hype [ ]

Use SSLsplit to transparently sniff TLS/SSL connections – including non-HTTP(S) protocols

I recently demonstrated how to perform a man-in-the-middle attack on HTTP(S) connections using mitmproxy. While mitmproxy works just great for HTTP-based communication, it does not understand other TLS/SSL-based traffic such as FTPS, SMTP over SSL, IMAP over SSL or any other protocol wrapped in TLS/SSL. SSLsplit is a generic transparent TLS/SSL proxy for performing man-in-the-middle [ ]

How To: DNS spoofing with a simple DNS server using Dnsmasq

The Domain Name System (DNS) is one of the fundamental services of the Internet. By resolving domain names to IP addresses, it makes routing of IP packets possible and thereby lets browsers and other clients connect to remote servers using all kinds of protocols. By blindly connecting to the IP address returned by the DNS [ ]

Send WhatsApp messages via PHP using WhatsAPI

I recently discovered that once you have acquired your WhatsApp account password, it s relatively easy to send and receive WhatsApp messages via PHP. Using the PHP-based framework WhatsAPI, a simple WhatsApp notifier script only has a dozen lines of code. This tiny tutorial shows how to use the two very basic functions of WhatsAPI, namely [ ]

How To: Sniff the WhatsApp password from your Android phone or iPhone

WhatsApp is a very popular SMS-like messenger for smartphones, but it s unfortunately only available for smartphones right now. If you want to use other tools or write web applications that send or receive WhatsApp messages (e.g. WhatsAPI, was at https://github.com/venomous0x/WhatsAPI, site now defunct, July 2019), you have to find a way to sniff the WhatsApp [ ]

How To: Use mitmproxy to read and modify HTTPS traffic

Capturing HTTP and HTTPS traffic on your own machine is quite simple: Using tools like Wireshark or Firebug, sniffing the local connections is only a matter of seconds. Capturing and/or altering the HTTP/HTTPS traffic of other machines in your network (such as your smartphone or other laptops) on the other hand is not so easy. [ ]

Script: Run rsnapshot backups only once and rollback failed backups using rsnapshot-once

I use rsnapshot to backup all of my data to my HTPC and home server (the home partition, office documents and the root file system). While rsnapshot is not as shiny as other backup tools, it is very flexible and effective: rsnapshot is based on rsync and makes hardlink-based backups (like cp -al), i.e. backups [ ]

Minimizing remote storage usage and synchronization time using deduplication and multichunking: Syncany as an example

This post introduces my Master s thesis Minimizing remote storage usage and synchronization time using deduplication and multichunking: Syncany as an example . I submitted the thesis in January 2012, and now found a little time to post it here. The key goal of this thesis was to determine the suitability of deduplication for end-user applications [ ]

Restart LIRC if remote control is reconnected using a udev rule

I recently built myself a new HTPC. It s controlled with a Medion X10 remote control using LIRC. For some reason, LIRC doesn t realize when the USB dongle for my remote control is reconnected (unplug USB, plug it back in). This blog posts demonstrates how to easily fix this using a udev rule. I originally posted [ ]

Java: Encode any byte array, stream or file into a 24-bit bitmap image (BMP)

In some situations it is necessary to hide binary data in another file format so that it cannot be easily detected be it to store data on image storage platforms such as Picasa, or to circumvent firewalls or mail filters. I wrote a little helper to encode byte arrays, streams or files into 24-bit [ ]

Meet my first HTPC: Fanless, NAS/RAID1, Linux, 30 watts, 24×7, FC10, XBMC

I recently built myself a new and shiny HTPC for my living room, and because it took lots of time researching the right components, I d like to share my experiences. I published this post first on the XBMC forum a couple of days ago. Feel free to comment either here or there. Lots of pictures [ ]

Script: Refresh the Fritz!Mediaserver DLNA Index of the Fritz!Box 6360 Cable

Some of AVM s Fritz!Box routers allow connecting a USB device and use this device as a network attached storage (NAS) via Samba/SMB in the local network. In combination with the fact that the NAS can also be accessed from the Internet via FTP, and the multimedia files can be streamed to a TV via the [ ]

Script: Your US proxy server in one minute using Amazon EC2

Many of the well known websites determine your location based on your IP address and restrict their content or functionalities based on the country you re in. Some examples are Gmail (Germans get only @googlemail.com-addresses, legal reasons), YouTube (content is restricted by the GEMA), and Pandora (limited to US citizens) to name only a few. To [ ]

Android Example: Communication between Activity and Service using Messaging

I recently wrote my first little app for my Android smartphone and I was surprised how easy it was. Being familiar with regular Java, learning the new Android APIs was very simple for the most part. However, there was one thing that wasn t particularly straight forward: communicating between an Activity, i.e. the user interface, and [ ]