Aggregator

Tackling L33t-Speak

2 months 1 week ago
Tackling L33t-Speak Image Dave Taylor Thu, 04/05/2018 - 09:00 HOW-TOs Programming Shell Scripting

How to script a l33t-speak translator.

My daughter and I were bantering with each other via text message this morning as we often do, and I dropped into a sort of mock "leet speak". She wasn't impressed, but it got me thinking about formulaic substitutions in language and how they represent interesting programming challenges.

If you're not familiar with "leet speak" it's a variation on English that some youthful hackers like to use—something that obscures words sufficiently to leave everyone else confused but that still allows reasonably coherent communication. Take the word "elite", drop the leading "e" and change the spelling to "leet". Now replace the vowels with digits that look kind of, sort of the same: l33t.

There's a sort of sophomoric joy in speaking—or writing—l33t. I suppose it's similar to pig latin, the rhyming slang of East Londoners or the reverse-sentence structure of Australian shopkeepers. The intent's the same: it's us versus them and a way to share with those in the know without everyone else understanding what you're saying.

At their heart, however, many of these things are just substitution ciphers. For example, "apples and pears" replaces "stairs", and "baked bean" replaces "queen", in Cockney rhyming slang.

It turns out that l33t speak is even more formalized, and there's actually a Wikipedia page that outlines most of its rules and structure. I'm just going to start with word variations and letter substitutions here.

The Rules of L33t Speak

Okay, I got ahead of myself. There aren't "rules", because at its base, leet speak is a casual slang, so l33t and 733T are both valid variations of "elite". Still, there are a lot of typical substitutions, like dropping an initial vowel, replacing vowels with numerical digits or symbols (think "@" for "a"), replacing a trailing "s" with a "z", "cks" with "x" (so "sucks" becomes "sux"), and the suffixed "ed" becomes either 'd or just the letter "d".

All of this very much lends itself to a shell script, right? So let's test some mad skillz!

For simplicity, let's parse command-line arguments for the l33t.sh script and use some level of randomness to ensure that it's not too normalized. How do you do that in a shell script? With the variable $RANDOM. In modern shells, each time you reference that variable, you'll get a different value somewhere in the range of 1..MAXINT. Want to "flip a coin"? Use $(($RANDOM % 2)), which will return a zero or 1 in reasonably random order.

So the fast and easy way to go through these substitutions is to use sed—that old mainstay of Linux and UNIX before it, the stream editor. Mostly I'm using sed here, because it's really easy to use substitute/pattern/newpattern/—kind of like this:

word="$(echo $word | sed "s/ed$/d/")"

This will replace the sequence "ed" with just a "d", but only when it's the last two letters of the word. You wouldn't want to change education to ducation, after all.

Here are a few more that can help:

word="$(echo $word | sed "s/s$/z/")" word="$(echo $word | sed "s/cks/x/g;s/cke/x/g")" word="$(echo $word | sed "s/a/@/g;s/e/3/g;s/o/0/g")" word="$(echo $word | sed "s/^@/a/")" word="$(echo $word | tr "[[:lower:]]" "[[:upper:]]")"

In order, a trailing "s" becomes a trailing "z"; "cks" anywhere in a word becomes an "x", as does "cke"; all instances of "a" are translated into "@"; all instances of "e" change to "3"; and all instances of "o" become "0". Finally, the script cleans up any words that might start with an "a". Finally, all lowercase letters are converted to uppercase, because, well, it looks cool.

How does it work? Here's how this first script translates the sentence "I am a master hacker with great skills":

I AM A M@ST3R H@XR WITH GR3@T SKILLZ

That's a good start, but there's more you can do, something I'll pick up in my next article. Meanwhile, if you consider yourself a l33t expert, hit me up, let's talk about some additional letter, letter combination and word rules.

Dave Taylor

Tackling L33t-Speak

2 months 1 week ago
Tackling L33t-Speak Image Dave Taylor Thu, 04/05/2018 - 09:00 HOW-TOs Programming Shell Scripting

How to script a l33t-speak translator.

My daughter and I were bantering with each other via text message this morning as we often do, and I dropped into a sort of mock "leet speak". She wasn't impressed, but it got me thinking about formulaic substitutions in language and how they represent interesting programming challenges.

If you're not familiar with "leet speak" it's a variation on English that some youthful hackers like to use—something that obscures words sufficiently to leave everyone else confused but that still allows reasonably coherent communication. Take the word "elite", drop the leading "e" and change the spelling to "leet". Now replace the vowels with digits that look kind of, sort of the same: l33t.

There's a sort of sophomoric joy in speaking—or writing—l33t. I suppose it's similar to pig latin, the rhyming slang of East Londoners or the reverse-sentence structure of Australian shopkeepers. The intent's the same: it's us versus them and a way to share with those in the know without everyone else understanding what you're saying.

At their heart, however, many of these things are just substitution ciphers. For example, "apples and pears" replaces "stairs", and "baked bean" replaces "queen", in Cockney rhyming slang.

It turns out that l33t speak is even more formalized, and there's actually a Wikipedia page that outlines most of its rules and structure. I'm just going to start with word variations and letter substitutions here.

The Rules of L33t Speak

Okay, I got ahead of myself. There aren't "rules", because at its base, leet speak is a casual slang, so l33t and 733T are both valid variations of "elite". Still, there are a lot of typical substitutions, like dropping an initial vowel, replacing vowels with numerical digits or symbols (think "@" for "a"), replacing a trailing "s" with a "z", "cks" with "x" (so "sucks" becomes "sux"), and the suffixed "ed" becomes either 'd or just the letter "d".

All of this very much lends itself to a shell script, right? So let's test some mad skillz!

For simplicity, let's parse command-line arguments for the l33t.sh script and use some level of randomness to ensure that it's not too normalized. How do you do that in a shell script? With the variable $RANDOM. In modern shells, each time you reference that variable, you'll get a different value somewhere in the range of 1..MAXINT. Want to "flip a coin"? Use $(($RANDOM % 2)), which will return a zero or 1 in reasonably random order.

So the fast and easy way to go through these substitutions is to use sed—that old mainstay of Linux and UNIX before it, the stream editor. Mostly I'm using sed here, because it's really easy to use substitute/pattern/newpattern/—kind of like this:

word="$(echo $word | sed "s/ed$/d/")"

This will replace the sequence "ed" with just a "d", but only when it's the last two letters of the word. You wouldn't want to change education to ducation, after all.

Here are a few more that can help:

word="$(echo $word | sed "s/s$/z/")" word="$(echo $word | sed "s/cks/x/g;s/cke/x/g")" word="$(echo $word | sed "s/a/@/g;s/e/3/g;s/o/0/g")" word="$(echo $word | sed "s/^@/a/")" word="$(echo $word | tr "[[:lower:]]" "[[:upper:]]")"

In order, a trailing "s" becomes a trailing "z"; "cks" anywhere in a word becomes an "x", as does "cke"; all instances of "a" are translated into "@"; all instances of "e" change to "3"; and all instances of "o" become "0". Finally, the script cleans up any words that might start with an "a". Finally, all lowercase letters are converted to uppercase, because, well, it looks cool.

How does it work? Here's how this first script translates the sentence "I am a master hacker with great skills":

I AM A M@ST3R H@XR WITH GR3@T SKILLZ

That's a good start, but there's more you can do, something I'll pick up in my next article. Meanwhile, if you consider yourself a l33t expert, hit me up, let's talk about some additional letter, letter combination and word rules.

Dave Taylor

Subutai Blockchain Router v2.0, NixOS New Release, Slimbook Curve and More

2 months 1 week ago
Subutai Blockchain Router v2.0 NixOS New Release Slimbook Curve and More

News briefs for April 5, 2018.

Subutai recently announced that its Subutai Blockchain Router v2.0 is in production: "This broadband cloud router serves as a 'plug-and-play' cryptocurrency wallet and mining device with energy savings of 10x over traditional mining methods, and also allows users to share and rent their idle computer resources by registering their computers with the Subutai Bazaar."

NixOS released version 18.03 "Impala" yesterday. Highlights include "core version changes: linux: 4.9 -> 4.14, glibc: 2.25 -> 2.26, gcc: 6 -> 7, systemd: 234 -> 237"; "desktop version changes: gnome: 3.24 -> 3.26, (KDE) plasma-desktop: 5.10 -> 5.12"; the Nix package manager now defaults to 2.0 and more.

Matthew Garrett wrote a blog post yesterday titled "Linux Kernel Lockdown and UEFI Secure Boot" to elaborate on the kernel lockdown feature being paired with UEFI SecureBoot, in response to discussion on the LKML.

The Slimbook Curve—a new cool-looking, all-in-one Linux PC with a 24" full-HD curved screen—is now available from Spanish company Slimbook. See the OMG Ubuntu post for specs and pricing info.

LibreOffice 6.0.3 is available for download. This is the third minor release of LibreOffice 6, and it has about 70 bug and regression fixes. This version "represents the bleeding edge in terms of features and as such is targeted at early adopters, tech-savvy and power users, while LibreOffice 5.4.6—provided as an alternative download option—is targeted at mainstream users and enterprise deployments."

Jill Franklin

Subutai Blockchain Router v2.0, NixOS New Release, Slimbook Curve and More

2 months 1 week ago
Subutai Blockchain Router v2.0 NixOS New Release Slimbook Curve and More

News briefs for April 5, 2018.

Subutai recently announced that its Subutai Blockchain Router v2.0 is in production: "This broadband cloud router serves as a 'plug-and-play' cryptocurrency wallet and mining device with energy savings of 10x over traditional mining methods, and also allows users to share and rent their idle computer resources by registering their computers with the Subutai Bazaar."

NixOS released version 18.03 "Impala" yesterday. Highlights include "core version changes: linux: 4.9 -> 4.14, glibc: 2.25 -> 2.26, gcc: 6 -> 7, systemd: 234 -> 237"; "desktop version changes: gnome: 3.24 -> 3.26, (KDE) plasma-desktop: 5.10 -> 5.12"; the Nix package manager now defaults to 2.0 and more.

Matthew Garrett wrote a blog post yesterday titled "Linux Kernel Lockdown and UEFI Secure Boot" to elaborate on the kernel lockdown feature being paired with UEFI SecureBoot, in response to discussion on the LKML.

The Slimbook Curve—a new cool-looking, all-in-one Linux PC with a 24" full-HD curved screen—is now available from Spanish company Slimbook. See the OMG Ubuntu post for specs and pricing info.

LibreOffice 6.0.3 is available for download. This is the third minor release of LibreOffice 6, and it has about 70 bug and regression fixes. This version "represents the bleeding edge in terms of features and as such is targeted at early adopters, tech-savvy and power users, while LibreOffice 5.4.6—provided as an alternative download option—is targeted at mainstream users and enterprise deployments."

Jill Franklin

Mozilla Trumpets Altered Reality Browser

2 months 2 weeks ago
The Mozilla Foundation has unveiled its plans for Firefox Reality, a browser designed specifically for mixed reality headsets. The browser combines the beneftis of Mozilla's existing Firefox browser with its experimental Web engine. Using Servo, Mozilla plans to experiment with entirely new designs and technologies for seeing and interacting with the immersive Web.
John P. Mello Jr.