Africa Cup of Nations hosts Morocco secured their place in the final with a 4–2 penalty shootout victory over Nigeria.