Hospitals, major companies and government offices were hit by a virus that seeks to seize control of computers until the victims pay a ransom.