Copy/pasting your password into the Runescape Client

:: tricks, windows

In a fit of nostalgia, I wanted to play some Runescape this weekend. I discovered that Runescape forbids copy and pasting your password into the client, for bogus security reasons. This poses a problem for me, since my password is a very long randomly generated string. Normally, I would copy and paste it from my password manager.

Thankfully, a little Powershell scripting solves the problem. The script below will, upon execution, switch to the Runescape client and type your password. You need to configure one variable, $password, which should be set using a command the reads your password from your password manager (or, if you don’t care about security, set to your password as a string literal). The default uses my configuration, fetching the password from pass via WSL.

Be careful not to run the script while you’re already logged in, or it might enter your password in chat. It shouldn’t, and it won’t hit enter, but… use at your own risk.

runescaope-login.ps1

## --------------------------------------------------------------------
## Instructions:
# Launch Runescape then run this script while on the login page.
#
# You may need to switch Runescape between windowed and full screen 
# after, as alt-tabbing or this script sometimes screws up full screen.

## --------------------------------------------------------------------
## Configure:

# Your runescape password
# $password = "my hard coded password"
# $password = get-password-command
$password = (wsl /usr/bin/pass show runescape.com `| head -n 1)

# Delay.
# How long to wait between grabbing Runescape window and starting to type.
$delay = 1

## --------------------------------------------------------------------

function Show-Process($Process) {
  $sig = '
    [DllImport("user32.dll")] public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);
    [DllImport("user32.dll")] public static extern int SetForegroundWindow(IntPtr hwnd);
  '

  $type = Add-Type -MemberDefinition $sig -Name WindowAPI -PassThru
  $hwnd = $process.MainWindowHandle
  $null = $type::ShowWindowAsync($hwnd, 5)
  $null = $type::SetForegroundWindow($hwnd) 
}

Show-Process (Get-Process -Name rs2client)

timeout $delay

Add-Type -AssemblyName System.Windows.Forms 
$password.ToCharArray() | ForEach-Object {[System.Windows.Forms.SendKeys]::SendWait($_)}

Running a public server from WSL 2

:: linux, tricks, windows, wsl

This week, for ReAsOnS, I wanted to run a server on WSL 2 that was accessible from the internet. This was surprisingly involved and requires lots of hard-to-find tricks to forward ports through 4 different layers of network abstractions and firewalls.

  1. In WSL, make sure your server is using IPv4. I spent a hell of a long time just trying to figure out why I couldn’t access the server from localhost. I had successfully run a handful of local http servers from WSL that were accessible from the Windows host, so I wasn’t sure what the problem was. It turns out this server, written in Java, wouldn’t work until I added -Djava.net.preferIPv4Stack=true to the java options. It appears that Java was defaulting to IPv6, and WSL doesn’t forward IPv6 properly, or something.
  2. In WSL, make sure you allow the port through your WSL firewall, if you’re using one. Using a WSL firewall might be redundant, but you might be using one. I usually use ufw in my linux machines, so run I’d run ufw allow $PORT in WSL.
  3. In Windows, forward your port from the public IP port to the WSL port using netsh interface portproxy add v4tov4 listenport=$PORT listenaddress=0.0.0.0 connectport=$PORT connectaddress=127.0.0.1 in a Powershell with admin rights. This is one of the hard-to-find but necessary WSL specific bits. It look like Windows creates a virtual adapter that isn’t properly bridged with your internet network adapter. I tried playing various bridging tricks, but in the end, I had to manually create a portproxy rule using Windows’ network shell netsh. This listens on all addresses and forwards the connection to the localhost, which seems to be automatically bridged with WSL. You can also try to manually forward it to the WSL adapter. Use ipconfig to find it. However, the WSL IP changes from time to time, so I recommend using local host instead. It might also be wise to listen explicitly on your internet facing IP instead of 0.0.0.0, but this seemed to work.
  4. In Windows, allow the port through the Windows firewall explicitly by adding a new Inbound Rule using the Windows Defender Firewall with Advanced Security administrative tool. This is accessible as WF.msc in cmd and Powershell. Select Inbound Rule, and click New rule... in the action menu to the right, and work your way through the menu to allow the port explicitly. Normally, Windows asks if you want to allow applications through the firewall. This doesn’t seem to happen with WSL servers, so we have to manually add a rule.
  5. In your router, setup port forwarding for the port.

One inside perspective on the graduate student application process

:: academia

Around this time of year (graduate student recruiting season), I see lots of:

  1. Stress from students who are unsure about the graduate recruiting process and how their application is viewed.
  2. Reassurance from people who have been through the process, e.g.,:

https://twitter.com/TaliaRinger/status/1225981382708514817

What I don’t see much from professors explaining WTF.

I’ve now been on both sides of this process and wants to give a peak behind the mysterious curtain in an attempt to reduce stress from students currently going through this process, and hopefully help future students with their applications.

This started as a tweet thread; you can view the original here:

https://twitter.com/wilbowma/status/1226023671946330113

In this post, I maintain that thread and elaborate on it.

CS101: Introduction to Hammering

:: academia

In this post, I describe a proposal to redevelop the Construction Science introduction course to use hammers, a standard and state-of-the-art industry tool that students should have experience with.

How I Redex—Experimenting with Languages in Redex

:: research, tutorial

Recently, I asked my research assistant, Paulette, to create a Redex model. She had never used Redex, so I pointed her to the usual tutorials:

While she was able to create the model from the tutorials, she was left the question “what next?”. I realized that the existing tutorials and documentation for Redex do a good job of explaining how to implement a Redex model, but fail to communicate why and what one does with a Redex model.

I decided to write a tutorial that introduces Redex from the perspective I approach Redex while doing work on language models—a tool to experiment with language models. The tutorial was originally going to be a blog post, but it ended up quite a bit longer that is reasonable to see in a single page, so I’ve published it as a document here:

Experimenting with Languages in Redex

Untyped Programs Don’t Exist

:: research

Lately, I’ve been thinking about various (false) dichotomies, such as typed vs untyped programming and type systems vs program logics. In this blog post, I will argue that untyped programs don’t exist (although the statement will turn out to be trivial).

TLDR

All languages are typed, but may use different enforcement mechanisms (static checking, dynamic checking, no checking, or some combination). We should talk about how to use types in programming—e.g. tools for writing and enforcing invariants about programs—instead of talking about types and type checking as properties of languages.

The reviewers were right to reject my paper

:: academia, research

I submitted two papers to POPL 2018. The first, “Type-Preserving CPS Translation of Σ and Π Types is Not Not Possible”, was accepted. The second, “Correctly Closure-Converting Coq and Keeping the Types, Too” (draft unavailable), was rejected.

Initially, I was annoyed about the reviews. I’ve since reconsidered the reviews and my work, and think the reviewers were right: this paper needs more work.

What even is compiler correctness?

:: research

In this post I precisely define common compiler correctness properties. Compilers correctness properties are often referred to by vague terms such as “correctness”, “compositional correctness”, “separate compilation”, “secure compilation”, and others. I make these definitions precise and discuss the key differences. I give examples of research papers and projects that develop compilers that satisfy each of these properties.