Is there a better way to do this?
I set up a colour palette and just used
Paint.NET's Recolor tool set to 0 tolerance and a big enough brush size to cover the entire sprite so I know it recolours every pixel at once.
Then I just went colour by colour, picking the colour in one palette and the corresponding colour to replace in the other palette.
Finding the colours in the sprite was a bit tedious though.