Linux Fu: Literate Regular Expressions

Regular expressions — the things you feed to programs like grep — are a bit like riding a bike. It seems impossible until you learn to do it, and then it’s easy. Part of their bad reputation is because they use a very concise and abbreviated syntax that alarms people. To help people who don’t use regular expressions every day, I created a tool that lets you write them in something a little closer to plain English. Actually, I’ve written several versions of this over the years, but this incarnation that targets grep is the latest. Unlike some previous versions, this time I did it all using Bash.

Those who don’t know regular expressions might freak out when they see something like:

[0-9]{5}(-[0-9]{4})?

How long does it take to figure out what that does? What if you could write that in a more literate way? For example:

digit repeat 5 \

start_group \

   - digit repeat 4 \

end_group optional

Not as fast to type, sure. But you can probably deduce what it does: it reads US Zipcodes.

I’ve found that some of the most popular tools I’ve created over the years are ones that I don’t need myself. I’m sure you’ve had that experience, too. You know how to operate a computer, but you create a menu system for people who don’t and they love it. That’s how it is with this tool. You might not need it, but there’s a good chance you know someone who does. Along the way, the code uses some interesting features of Bash, so even if you don’t want to be verbose with your regular expressions, you might pick up a trick or two.

Continue reading “Linux Fu: Literate Regular Expressions”

A Free Software OS For The ReMarkable E-Paper Tablet

If you’re looking to rid your day to day life of dead trees, there’s a good chance you’ve already heard of the reMarkable tablet. The sleek device aims to replace the traditional notebook. To that end, remarkable was designed to mimic the feeling of writing on actual paper as closely as possible. But like so many modern gadgets, it’s unfortunately encumbered by proprietary code with a dash of vendor lock-in. Or at least, it was.

[Davis Remmel] has been hard at work porting Parabola, a completely free and open source GNU/Linux distribution, to the reMarkable. Developers will appreciate the opportunity to audit and modify the OS, but even from an end-user perspective, Parabola greatly opens up what you can do on the device. Before you were limited to a tablet UI and a select number of applications, but with this replacement OS installed, you’ll have a full-blown Linux desktop to play with.

You still won’t be watching videos or gaming on the reMarkable (though technically, you would be able to), but you could certainly use it to read and edit documents the original OS didn’t support. You could even use it for light software development. Since USB serial adapters are supported, microcontroller work isn’t out of the question either. All while reaping the considerable benefits of electronic paper.

The only downside is that the WiFi hardware is not currently supported as it requires proprietary firmware to operate. No word on whether or not [Davis] is willing to make some concession there for users who aren’t quite so strict about their software freedoms.

We’ve been waiting patiently for the electronic paper revolution to do more than replace paperbacks with Kindles, and devices like the reMarkable seem to be finally moving us in the right direction. Thankfully, projects that aim to bring free and open source software to these devices mean we won’t necessarily have to let Big Brother snoop through our files in the process.

Linux Fu: Moving /usr

Linux has changed. Originally inspired by Unix, there were certain well understood but not well enforced rules that everyone understood. Programs did small things and used pipes to communicate. X Windows servers didn’t always run on your local machine. Nothing in /usr contributed to booting up the system.

These days, we have systemd controlling everything. If you run Chrome on one display, it is locked to that display and it really wants that to be the local video card. And moving /usr to another partition will easily prevent you from booting up, unless you take precautions. I moved /usr and I lived to tell about it. If you ever need to do it, you’ll want to hear my story.

A lot of people are critical of systemd — including me — but really it isn’t systemd’s fault. It is the loss of these principles as we get more programmers and many of them are influenced by other systems where things work differently. I’m not just ranting, though. I recently had an experience that brought all this to mind and, along the way, I learned a few things about the modern state of the boot process. The story starts with a friend giving me an Intel Compute Stick. But the problems I had were not specific to that hardware, but rather how modern Linux distributions manage their start-up process.

Continue reading “Linux Fu: Moving /usr”

Checking In On The Damn Linux Tablet One

Tablets, slates, phones, and fablets, there are no shortage of electronics that take the Star-Trek-ish form factor of a handheld rectangle of glass that connects you to everything. This is the world we live in, but unfortunately it’s not currently a world with many Linux options, and certainly not one that includes modular design concepts. This is what motivated [Timon] to design the Damn Linux Table one, a “Proper Linux Tablet” built around the Nvidia Jetson Nano board.

The design really took off, because who isn’t interested in the ability to upgrade and customize a tablet? During last year’s Hackaday Supercon we caught up with [Timon] for an interview the morning after he won the Best Design prize for DLT one. Check out that video below, then join us after the break for an update on the latest from the project.

There’s only one week left to get your project entered in the 2020 Hackaday Prize. We won’t know this year’s winners until the Hackaday Remoticon rolls around this November. The Call for Proposals for that virtual conference is still open!

[Timon] is realistic about the limits of modular design. He readily admits you’re not going to upgrade a graphics card on a mobile device, but when it comes to the peripherals, why not? You might want to choose between micro-USB, USB-C, barrel-jack, or do something completely custom. One hacker’s NFC equipment might be replaced by another’s SDR or LoRa. This tablet design sees a world where connecting PCIe components to your mobile devices is completely doable. The point is to make a base model that works great, but has the potential to be what each different user wants their device to be.

Continue reading “Checking In On The Damn Linux Tablet One”

Linux-Fu: Your Own Dynamic DNS

It is a problem as old as the Internet. You want to access your computer remotely, but it is behind a router that randomly gets different IP addresses. Or maybe it is your laptop and it winds up in different locations with, again, different IP addresses. There are many ways to solve this problem and some of them are better than others.

A lot of routers can report their IP address to a dynamic DNS server. That used to be great, but now it seems like many of them hound you to upgrade or constantly renew so you can see their ads. Some of them disappear, too. If your router vendor supplies one, that might be a good choice, until you change routers, of course. OpenWRT supports many such services and there are many lists of common services.

However, if you have a single public accessible computer, for example a Web server or even a cloud instance, and you are running your own DNS server, you really don’t need one of those services. I’m going to show you how I do it with an accessible Linux server running Bind. This is a common setup, but if you have a different system you might have to adapt a bit.

There are many ways to set up dynamic DNS if you are willing to have a great deal of structure on both sides. Most of these depend on setting up a secret key to allow for DNS updates and some sort of script that calls nsupdate or having the DHCP server do it. The problem is, I have a lot of client computers and many are set up differently. I wanted a system where the only thing needed on the client side was ssh. All the infrastructure remains on the DNS server.

Continue reading “Linux-Fu: Your Own Dynamic DNS”

FBI Reports On Linux Drovorub Malware

The FBI and the NSA released a report on the Russian-based malware that attacks Linux known as Drovorub (PDF) and it is an interesting read. Drovorub uses a kernel module rootkit and allows a remote attacker to control your computer, transfer files, and forward ports. And the kernel module takes extraordinary steps to avoid detection while doing it.

What is perhaps most interesting though, is that the agencies did the leg work to track the malware to its source: the GRU — Russian intelligence. The name Drovorub translates into “woodcutter” and is apparently the name the GRU uses for the program.

A look inside the code shows it is pretty mundane. There’s a server with a JSON configuration file and a MySQL backend. It looks like any other garden-variety piece of code. To bootstrap the client, a hardcoded configuration allows the program to make contact with the server and then creates a configuration file that the kernel module actively hides. Interestingly, part of the configuration is a UUID that contains the MAC address of the server computer.

The rootkit won’t persist if you have UEFI boot fully enabled (although many Linux computers turn UEFI signing off rather than work through the steps to install an OS with it enabled). The malware is easy to spot if you dump raw information from the network, but the kernel module makes it hard to find on the local machine. It hooks many kernel functions so it can hide processes from both the ps command and the /proc filesystem. Other hooks remove file names from directory listings and also hides sockets. The paper describes how to identify the malware and they are especially interested in detection at scale — that is, if you have 1,000 Linux PCs on a network, how do you find which ones have this infection?

This is a modern spy story, but not quite what we’ve come to expect in Bond movies. “Well, Moneypenny, it appears Spectre is using the POCO library to generate UUIDs,” is hard to work into a trailer. We prefer the old days when high-tech spying meant nonlinear junction detectors, hacking Selectrics, moon probe heists, and passive bugging.

Exotic Device Gets Linux Support Via Wireshark And Rust

What can you do if you have a nice piece of hardware that kinda works out of the box, but doesn’t have support for your operating system to get the full functionality out of it? [Harry Gill] found himself in such a situation with a new all-in-one (AIO) water cooling system. It didn’t technically require any operating system interaction to perform its main task, but things like settings adjustments or reading back statistics were only possible with Windows. He thought it would be nice to have those features in Linux as well, and as the communication is done via USB, figured the obvious solution is to reverse engineer the protocol and simply replicate it.

His first step was to set up a dual boot system (his attempts at running the software in a VM didn’t go very well) which allowed him to capture the USB traffic with Wireshark and USBPcap. Then it would simply be a matter of analyzing the captures and writing some Linux software to make sense of the data. The go-to library for USB tasks would be libusb, which has bindings for plenty of languages, but as an avid Rust user, that choice was never really an issue anyway.

How to actually make use of the captured data was an entirely different story though, and without documentation or much help from the vendor, [Harry] resorted to good old trial and error to find out which byte does what. Eventually he succeeded and was able to get the additional features he wanted supported in Linux — check out the final code in the GitHub repository if you’re curious what this looks like in Rust.

Capturing the USB communication with Wireshark seems generally a great way to port unsupported features to Linux, as we’ve seen earlier with an RGB keyboard and the VGA frame grabber that inspired it. If you want to dig deeper into the subject, [Harry] listed a few resources regarding USB in general, but there’s plenty more to explore with reverse engineering USB.