Dridex malware
Dridex malware has been used to infect thousands of computers in the U.S. and U.K. allowing the criminal gang behind it to steal at least $40 million. Reuters

Two of the Internet's largest pornography websites have been hit by a malware attack through their advertising networks. Malwarebytes discovered that the ExoClick ad network had been serving up what seemed like legitimate code as an ad banner. Cookiecheck.js, as it is known, was first spotted on Sept. 19.

The news is a severe blow to two of the Internet's most visited websites. According to stats from SimilarWeb, more than 580 million visits were made to Pornhub.com in August 2015 alone, while YouPorn.com received just under 220 million visits in the same period. Pornhub and YouPorn have Alexa global rankings of 65 and 161 respectively.

Both publishers and ad networks worked to remove the offending code immediately, with the offending third party -- which was not identified -- immediately being suspended from advertising on the sites. A statement from site group owner Mindgeek released to Malwarebytes said, "Providing an optimal and secure customer experience is of topmost priority for Pornhub, and our organization has taken the necessary steps to protect our customer’s enjoyment without the threat of infection. It is important to note that our sites are not delivering malware and we will continue to actively monitor the situation to safeguard our users."

It is not the first instance of a malware attack on a porn site. Just last week, xHamster was hit by a malicious advertisement that pretended to advertise a dating application called "Sex Messenger," specifically targeting users running Microsoft's Internet Explorer browser. In that instance, advertising provider TrafficHaus quickly removed the ad.

While antivirus software can help stop infections, it is not foolproof. Users who do not keep their antivirus up to date can find themselves at risk, as can those who avoid installing crucial Windows Updates (or updates for any other operating system). With that said, it's still possible to be at risk from infection, and one of the best ways to avoid infection is to avoid visiting sites or clicking on advertisements that look suspicious.