Bulk-renaming Video Snapshots

For reasons that should be obvious by now, I review the helmet camera video from (some of) our bike rides and extract snapshots of interesting events. VLC auto-names the snapshots along these lines:

-rw-rw-r-- 1 ed ed  4.0M 2016-09-16 16:15 vlcsnap-2016-09-16-16h15m43s49.png
-rw-rw-r-- 1 ed ed  3.2M 2016-09-16 16:15 vlcsnap-2016-09-16-16h15m59s181.png
-rw-rw-r-- 1 ed ed  2.7M 2016-09-16 16:18 vlcsnap-2016-09-16-16h18m58s125.png
-rw-rw-r-- 1 ed ed  3.7M 2016-09-16 18:40 vlcsnap-2016-09-16-18h40m22s7.png
-rw-rw-r-- 1 ed ed  3.5M 2016-09-16 18:40 vlcsnap-2016-09-16-18h40m58s132.png
-rw-rw-r-- 1 ed ed  3.5M 2016-09-16 18:41 vlcsnap-2016-09-16-18h41m29s181.png
-rw-rw-r-- 1 ed ed  3.9M 2016-09-16 18:41 vlcsnap-2016-09-16-18h41m42s60.png
-rw-rw-r-- 1 ed ed  3.8M 2016-09-16 18:41 vlcsnap-2016-09-16-18h41m54s146.png
-rw-rw-r-- 1 ed ed  3.8M 2016-09-16 18:42 vlcsnap-2016-09-16-18h42m22s206.png
-rw-rw-r-- 1 ed ed  3.7M 2016-09-16 18:42 vlcsnap-2016-09-16-18h42m38s58.png

The gap in the timestamp after the first three files reveals a random errand.

First, convert to JPG format, place the results in another directory and, en passant, mash them to a reasonable size:

mkdir /some-useful-directory/Road\ Repair/"Rt 82 and CR 29"
for f in  vlcsnap-2016-09-16* ; do convert $f -density 300 -define jpeg:extent=200KB /some-useful-directory/Road\ Repair/"Rt 82 and CR 29"/${f%%.*}.jpg ; done
cd /some-useful-directory/Road\ Repair/"Rt 82 and CR 29"

Replace the first part of the VLC-generated names with relevant identification:

rename 's/vlcsnap-/Rt 82 - /' vlcsnap-2016-09-16-16*
rename 's/vlcsnap-/CR 29 - /' vlcsnap*

The directory now contains these files:

-rw-rw-r-- 1 ed ed 193K 2016-09-19 11:36 CR 29 - 2016-09-16-18h40m22s7.jpg
-rw-rw-r-- 1 ed ed 192K 2016-09-19 11:36 CR 29 - 2016-09-16-18h40m58s132.jpg
-rw-rw-r-- 1 ed ed 193K 2016-09-19 11:36 CR 29 - 2016-09-16-18h41m29s181.jpg
-rw-rw-r-- 1 ed ed 193K 2016-09-19 11:36 CR 29 - 2016-09-16-18h41m42s60.jpg
-rw-rw-r-- 1 ed ed 194K 2016-09-19 11:36 CR 29 - 2016-09-16-18h41m54s146.jpg
-rw-rw-r-- 1 ed ed 196K 2016-09-19 11:36 CR 29 - 2016-09-16-18h42m22s206.jpg
-rw-rw-r-- 1 ed ed 196K 2016-09-19 11:36 CR 29 - 2016-09-16-18h42m38s58.jpg
-rw-rw-r-- 1 ed ed 195K 2016-09-19 11:36 Rt 82 - 2016-09-16-16h15m43s49.jpg
-rw-rw-r-- 1 ed ed 194K 2016-09-19 11:36 Rt 82 - 2016-09-16-16h15m59s181.jpg
-rw-rw-r-- 1 ed ed 194K 2016-09-19 11:36 Rt 82 - 2016-09-16-16h18m58s125.jpg

These bursts of Perl regex line noise replace the snapshot timestamp on those files with an ascending sequence number, with separate sequences for each group:

i=1 ; for f in CR* ; do rename -v "s/-1[68]h..m..s\d{1,3}/ - $(( i++ ))/" "$f" ; done
i=1 ; for f in Rt* ; do rename -v "s/-1[68]h..m..s\d{1,3}/ - $(( i++ ))/" "$f" ; done

And then the files make sense:

-rw-rw-r-- 1 ed ed 193K 2016-09-19 13:51 CR 29 - 2016-09-16 - 1.jpg
-rw-rw-r-- 1 ed ed 192K 2016-09-19 13:51 CR 29 - 2016-09-16 - 2.jpg
-rw-rw-r-- 1 ed ed 193K 2016-09-19 13:51 CR 29 - 2016-09-16 - 3.jpg
-rw-rw-r-- 1 ed ed 193K 2016-09-19 13:51 CR 29 - 2016-09-16 - 4.jpg
-rw-rw-r-- 1 ed ed 194K 2016-09-19 13:51 CR 29 - 2016-09-16 - 5.jpg
-rw-rw-r-- 1 ed ed 196K 2016-09-19 13:51 CR 29 - 2016-09-16 - 6.jpg
-rw-rw-r-- 1 ed ed 196K 2016-09-19 13:51 CR 29 - 2016-09-16 - 7.jpg
-rw-rw-r-- 1 ed ed 195K 2016-09-19 13:51 Rt 82 - 2016-09-16 - 1.jpg
-rw-rw-r-- 1 ed ed 194K 2016-09-19 13:51 Rt 82 - 2016-09-16 - 2.jpg
-rw-rw-r-- 1 ed ed 194K 2016-09-19 13:51 Rt 82 - 2016-09-16 - 3.jpg

The hard part, this time around, involved figuring a regex for the timestamp. The trick was to specify a single digit for the milliseconds part, with a repetition count allowing for one-to-three digits.

The Perl regex cheat sheet helped.

The double quotes around the rename search parameter allows the shell to expand the $(( i++ )) gibberish. The double quotes around the file name keep the blank-separated parts together.

At some point I must figure out how to produce leading-zero-filled sequence numbers, which will probably involve a printf.

The ride covered some roads with “2 to 4 foot” shoulders, which seems overly optimistic:

Rt 82 - 2016-09-16 - 3
Rt 82 – 2016-09-16 – 3

NYSDOT and DCDPW both believe a homeopathic strip of asphalt will cover faults in the travel lane and don’t care that the right side of the strip puts an abrupt ledge along the middle of the minimal and fissured shoulder:

Rt 82 - 2016-09-16 - 1
Rt 82 – 2016-09-16 – 1

Ah, well, it was a lovely day for a ride …

Why Friends Don’t Let Friends Run Windows: Cryptolocker Downloader

Got an email, nominally from one Richard Gilmore of FedEx, concerning a parcel sent as International Next Flight (whatever that is). The Subject line read “We could not deliver your parcel, #00000665103”, although the message didn’t quite match:

Dear Customer,

This is to confirm that one or more of your parcels has been shipped.
Delivery Label is attached to this email.

Kind regards,
Richard Gilmore,
Sr. Delivery Agent.

The email address had nothing to do with FedEx, of course, and my filters tagged it as spam.

The “label” came in a ZIP file: Label_00000665103.zip

Extracting the “label” produced what would look like an MS Word file, if you were so trusting as to hide extensions of “known” filetypes and didn’t worry when you saw a file still sporting a DOC extension: Label_00000665103.doc.wsf

Handing that to VirusTotal produces no surprise at all:

VirusTotal Report
VirusTotal Report

The file contains one very long line, the first chunk of which suggests it’s up to no good:

<job><script language=JScript>var a59253 = '+"HKCU"+cs'; var a59168 = '"); fp.WriteLine(" '; var a5988 = ';} else if('; var a59196 = 'gth;i'; var a59160 = 'fp.W'; var a59261 = 'ion"+c'; var a5999 = 's(f'; var a59254 = '+"SOFTWARE"+';

After a bit of poking, I applied a few minutes of sed reformatting, manual cleanup, and sorting:

sed 's/; var a/;\n/g' Label_00000665103.doc.wsf > lines.txt
... fix a few lines ...
sort -n lines.txt > sort.txt

Which produced a file starting out like this:

<job><script language=JScript>
590 = 'var id="TRIB9RMvAFl04U4Fi7L6RNk9ZowJ2sj_fIrO0WiXGlXd53j6oENCCFDZ9NbVubN-vvJltoR8Wf4_";d';
591 = '="1vcs62wsoYZNc4TdwqgsG5965bDt3mNYW"; var bc="0.52';
592 = '189"; var ld=0;';
593 = ' var cq';
594 = '=S';
595 = 'tri';
596 = 'ng.f';
597 = 'romCharCode(34);';
598 = ' var cs';
599 = '=Strin';
5910 = 'g.fromCh';
5911 = 'ar';
5912 = 'Code(92); var ll';
5913 = '=["32jelen.pl","v';
5914 = 'iktoriascho';
5915 = 'ol.ru","blende';
5916 = 'r.com.br';
5917 = '","pasargad1007.c';
5918 = 'om","www.unit';
5919 = 'ed-systems.it"';
5920 = ']; v';
5921 = 'ar ';
5922 = 'ws=WScript.Cre';
5923 = 'ateObject(';
5924 = '"WScript.Shell';
5925 = '"); v';
5926 = 'ar';
5927 = ' fn=ws';
5928 = '.Expa';
5929 = 'ndEnv';
5930 = 'ironme';
5931 = 'ntString';
... snippage ...

Even without pasting the fragments back together, you can puzzle out the punchline:

59108 = 't",true); fp.Write';
59109 = 'Line("ATTEN';
59110 = 'TION!"); fp.Wr';
59111 = 'ite';
59112 = 'Line(';
59113 = '""); fp.W';
59114 = 'riteLine("All';
59115 = ' your d';
59116 = 'ocuments, p';
59117 = 'hotos';
59118 = ', databases and ot';
59119 = 'her import';
59120 = 'ant ';
59121 = 'pers';
59122 = 'onal fil';
59123 = 'es"); fp.';
59124 = 'Wri';
59125 = 'te';
59126 = 'Line(';
59127 = '"were e';
59128 = 'ncrypted usi';
59129 = 'ng strong RSA-1024';
59130 = ' algorithm with ';
59131 = 'a uniqu';
59132 = 'e key."); fp.Write';
59133 = 'Line(';
59134 = '"To restor';
59135 = 'e your files you h';
59136 = 'ave to pay "+bc+" ';
59137 = 'BTC (bitcoin';
59138 = 's)."); fp.Wri';

Huh. CryptoLocker returns from the dead! Right now, 0.52 BTC = $316.15, so I guess I can drop that into the jar of money saved by running Linux.

If those emails didn’t work so well, they wouldn’t send them…

APRS iGate KE4ZNU-10: Southern Coverage

A pleasant Friday morning ride with several stops:

KE4ZNU-9 - APRS Reception - 2016-09-09
KE4ZNU-9 – APRS Reception – 2016-09-09

KE4ZNU-10 handled the spots near Red Oaks Mill, along parts of Vassar Rd that aren’t hidden by that bluff, and along Rt 376 north of the airport.

The KB2ZE-4 iGate in the upper left corner caught most of the spots; it has a much better antenna in a much better location than the piddly mobile antenna in our attic.

Several of the spots along the southern edge of the trip went through the K2PUT-15 digipeater high atop Mt. Ninham near Carmel, with coverage of the entire NY-NJ-CT area.

The APRS-IS database filters out packets received by multiple iGates, so there’s only one entry per spot.

All in all, KE4ZNU-10 covers the southern part of our usual biking range pretty much the way I wanted.

Vacuum Tube LEDs: Octal Tube Base Drilling

Clamping the octal tube into the Sherline let me set the XY=0 origin to the center of the base with the laser dot (visible near the front):

Octal tube clamped on Sherline mill
Octal tube clamped on Sherline mill

Find the edges, touch off the half the 32.2 mm diameter, then align the drill at XY=0 directly over the exposed evacuation tip:

Octal Tube - drill alignment
Octal Tube – drill alignment

Make a very shallow cut to verify the alignment:

Octal Tube - drill first touch
Octal Tube – drill first touch

Just inside the scuffed ring from the drill, you can see the fractured ring where the original one-piece Bakelite spigot / key / post broke off.

Then extract the drill from the chuck, file more relief behind the cutting edges so they actually cut, re-chuck, and continue the mission:

Octal Tube - drilling
Octal Tube – drilling

Pick a nice Bakelite ring out of the drill:

Octal Tube - drilled ring
Octal Tube – drilled ring

And eventually you can see all the way to the glass envelope:

Octal Tube - base opening
Octal Tube – base opening

The (knockoff) Neopixel LED sits directly below the evacuation tip and is about the same diameter, so much of that enlarged opening will be in shadow. Despite that, the tube does seem noticeably brighter:

Octal Tube - drilled base opening
Octal Tube – drilled base opening

Drilling that tube was so harrowing that I can’t imagine similar surgery on an intact octal base.

Perhaps just slicing off the tip of the Bakelite spigot and gluing a single very bright red/orange LED in place, rather using than a (knockoff) Neopixel a few millimeters away, will suffice.

Or just give up, top-light these tubes, and move on?

Octal Tube Base Clamp

One of the octal tubes in my collection has a broken spigot / key post that lets some light in through the bottom of the normally opaque Bakelite base:

Octal socket in CD - LED diffraction
Octal socket in CD – LED diffraction

Perhaps drilling out the base would let more light pass around the evacuation tip, but that requires a shell drill to clear the tip. Some doodling suggested a drill with 12 mm OD and 8 mm ID, which was close enough to one of the smaller homebrew drills in my collection that I decided to see how it worked:

Shell drill assortment
Shell drill assortment

You (well, I) can’t freehand such a hole, particularly with a glass tip in the middle, so I needed a way to clamp the tube in either the drill press or the Sherline. A pad for the clamp screw in a V-block seemed appropriate:

Vacuum Tube Lights - Octal base clamp - Slic3r preview
Vacuum Tube Lights – Octal base clamp – Slic3r preview

The screw hole sits at the 1/3 point to put more pressure near the pin end of the base. Maybe that matters.

The setup looks like this, with a small red laser dot near the front of the base:

Octal tube clamped on Sherline mill
Octal tube clamped on Sherline mill

The tube rests on a random scrap of plastic, with the hope that the drill won’t apply enough pressure to break the glass envelope.

In normal use, the V-block would be oriented the other way to let you cross-drill the cylinder. In this end-on orientation, drilling torque can rotate the tube; compliant padding for more traction may be in order.

The OpenSCAD source code as a GitHub Gist now includes a module that spits out the clamp:

Road Conditions: Rt 376 SB Near Maloney Rd

NYSDOT seems oddly reluctant to perform routine brush clearing along Rt 376 from Red Oaks Mill to the Hamlet of New Hackensack, despite the obvious hazard presented by the bushes:

Rt 376 SB shoulder overgrowth - 2016-09
Rt 376 SB shoulder overgrowth – 2016-09

I’ve reported this situation several times over the years, but, as you’ve seen in other situations, that has no effect.

If it were a pleasant back-country lane, rather than our main route to the Dutchess Rail Trail, perhaps having the greenery take over the shoulder wouldn’t matter quite so much:

Rt 376 SB - semitrailer
Rt 376 SB – semitrailer

Turns out the shoulder just north of Maloney has developed lethal cracks as the pavement subsides into the adjoining section of the Mighty Wappinger Creek. A bit more clearance would still be nice.

Internet Of Things, Banking Division

We were sitting in the Credit Union and, as usual, I scouted out the WiFi situation:

IoT Thermostat in the Credit Union
IoT Thermostat in the Credit Union

Huh. Not what you’d expect to find in a bank lobby.

In case you haven’t seen what can happen with a thermostat, you can pwn a Nest.

Searching with the obvious keywords should provide plenty of reasons why the Internet of Things isn’t ready for prime time, not that that will slow it down in the least.