The same way they got ahold of nuclear weapons knowledge.
So anyhow, it's not like a footrace where the major nuclear powers are at the finish line and NK is trying to catch up. They're following their own path appropriate for the situation they're in.
- I don't think the chronological order in which we've developed technologies matches up with the difficulties of cloning/repurposing/using them. I wouldn't expect NK to be able to put a man on the moon prior to, say, being able to make a Facebook clone.
- not everything is being invented from scratch. If individuals can smuggle data and devices in, do you doubt the military acting with the full resources of the country couldn't manage the same?