Hackers posing as a trusted advertiser tried to trick NYTimes.com visitors into believing their computers were infected so they would buy a fake anti-virus product, the paper has revealed.