The ransomware, also known as WannaCry, works by leveraging a Windows vulnerability that came to light last month when a cache of mysterious hacking tools was leaked on the internet.
The tools, which security researchers suspect came from the NSA, include an exploit codenamed EternalBlue that makes hijacking older Windows systems easy. It specifically targets the Server Message Block (SMB) protocol in Windows, which is used for file-sharing purposes.
https://www.rt.com/news/388153-thousands-ransomeware-attacks-worldwide/
http://www.telegraph.co.uk/news/2017/05/12/nhs-hit-major-cyber-attack-hackers-demanding-ransom/
http://www.independent.co.uk/life-style/gadgets-and-tech/news/nhs-cyber-attack-hack-ransomware-world-global-security-safety-privacy-a7733236.html