It is possible for spirits to sexually attack people. The sexual attack feels no different than a rape committed by a human being. The only difference is that the rapist is invisible. Such spirits are usually attracted to people who have unfulfilled sexual desires or unresolved sexual wounds. For example, people who feel lonely, deprived of intimacy, and/or addicted to pornography have tendencies to attract such spirits. We also find that people who have been sexually molested in their childhood may often attract spirits.
There is another group of people who consciously agree to have sex with a spirit. Soon they discover that the spirit desires to have sex on a frequent basis and on its own terms. This is typically when people seek help because they become overwhelmed with their situation.
Most people don't even realize how many people are raped by spirits day in day out, and every night. The ghost-rapist can be our life's partner or a complete stranger. It can be one spirit or a whole multitude. It's also worth to mentioning the matter of compulsive masturbation. Many men believe that since they feel this compulsion they must be mentally ill. Masturbation can be caused by spirit attachments.
For more information on this topic please refer to Wanda Pratnicka's book "Possessed by Ghosts", Chapter: Rapes