The earliest memory I have of ‘programming’ is in the early/mid 90s when my father brought home a computer from work. We could play games on it … so of course I took the spreadsheet program he used (LOTUS 123, did I date myself with that?) and tried to modify it to print out a helpful message for him. It … halfway worked? At least I could undo it so he could get back to work…

After that, I picked up programming for real in QBASIC (I still have a few of those programs lying around), got my own (junky) Linux desktop from my cousin, tried to learn VBasic (without a Windows machine), and eventually made it to high school… In college, I studied computer science and mathematics, mostly programming in Java/.NET, although with a bit of everything in the mix. A few of my oldest programming posts on this blog are from that time.

After that, on to grad school! Originally, I was going to study computational linguistics, but that fell through. Then programming languages (the school’s specialty). And finally I ended up studying censorship and computer security… before taking a hard turn into the private sector to follow my PhD advisor.

Since then, I’ve worked in the computer security space at a couple of different companies. Some don’t exist any more, some you’ve probably heard of. I still program for fun too, and not just in security.

But really, I still have a habit of doing a little bit of everything. Whatever seems interesting at the time!

AoC 2017 Day 18: Duetvm

Source: Duet

Part 1: Create a virtual machine with the following instruction set:

  • snd X plays a sound with a frequency equal to the value of X
  • set X Y sets register X to Y
  • add X Y set register X to X + Y
  • mul X Y sets register X to X * Y
  • mod X Y sets register X to X mod Y
  • rcv X recovers the frequency of the last sound played, if X is not zero
  • jgz X Y jumps with an offset of the value of Y, iff X is greater than zero

In most cases, X and Y can be either an integer value or a register.

What is the value recovered by rcv the first time X is non-zero?

read more...


SSH Config ProxyCommand Tricks

Working in security/operations in the tech industry, I use SSH a lot. To various different machines (some with hostnames, some without), using various different users and keys, and often (as was the case in my previous post) via a bastion host. Over the years, I’ve collected a number of SSH tricks that make my life easier.

read more...


AoC 2017 Day 17: Spinlock

Source: Spinlock1

Part 1: Start with a circular buffer containing [0] and current_position = 0. For n from 1 up to 2017:

  1. Step forward steps (puzzle input)
  2. Input the next value for n, set current_position to n, increment n
  3. Repeat

What is the value after 2017?

It’s a bit weird to describe, but the given example helps (assume steps = 3):

(0)
0 (1)
0 (2) 1
0  2 (3) 1
0  2 (4) 3  1
0 (5) 2  4  3  1
0  5  2  4  3 (6) 1
0  5 (7) 2  4  3  6  1
0  5  7  2  4  3 (8) 6  1
0 (9) 5  7  2  4  3  8  6  1

read more...


AoC 2017 Day 13: Firewall Puncher

Source: Packet Scanners

Part 1: Multiple layers are defined with rules of the form:

  • {index}: {depth}

Each layer will start at position 0, then once per tick will advance towards depth. Once it hits depth-1, it will return to position 0, taking 2*depth-1 per full cycle.

Calculate the sum of index * depth for any scanners that are at position 0 when you pass through them given an initial starting time.

read more...


Dynamic Automatic Proxies

On of the advantages of working in computer programming is that I can work from anywhere I have a computer and an internet connection. One of the disadvantages is that many of the resources that I need to do my job are locked to only be accessible within a specific network (albeit with a bastion host).

I long ago set up my SSH config to create an SSH tunnel and I can proxy many applications through that just by setting the HTTP_PROXY and/or HTTPS_PROXY environment variables. The downside of this though is that if I’m actually on a ‘safe’ network, there’s no reason to use the bastion host and I would actually be putting extra load on it.

My goal: write something that would let me automatically proxy applications when I need to but not when I don’t.

read more...