Even as executives from Google and Facebook prepare to testify in front of the Senate on how they're combating extremist content, the internet giants are struggling to keep it off their sites.

Dozens of accounts on sites owned by those two companies have been used this week to promote violent attacks and recruit people to the cause of Islamic terrorism, a CNBC investigation has found.

All of the content that was brought to the attention of Google and Facebook by CNBC was removed within 24 hours of notification. Yet many of the posts and videos, which contained graphic images and threats of violence, had been online for days or weeks before we alerted them to it.

Its presence on their pages underscores the enormous challenge these internet firms have in controlling content while remaining open platforms.

"Terrorists are using Google and Facebook technology to run what are essentially sophisticated social media marketing campaigns," said Eric Feinberg, co-founder of the Global Intellectual Property Enforcement Center, or GIPEC, which tracks extremist content online.

Extremist groups are using their tools the way brand advertisers and other online marketers do, cross-promoting videos on one account with posts on other social media services.

Facebook, YouTube and Twitter are sending representatives to Washington, D.C., on Wednesday morning to testify in front of the Senate Commerce Committee in a hearing titled "Terrorism and Social Media: #IsBigTechDoingEnough?"

CNBC initially discovered some of the violent videos and posts while reporting an earlier story on Facebook users who had been locked out of their accounts by hackers.

After that story was published, CNBC reported its findings to counter-terrorism officials at the U.S. Attorney's Office in San Francisco, because some of the content appeared to include coded messages about potential attacks over the Christmas holiday.

The office acknowledged receipt of our e-mail and said it couldn't comment further.

We then contacted GIPEC, a cyber-intelligence firm whose patented software finds social media activity produced by criminals and terrorists, and asked Feinberg if the group could locate more violent and extremist content.

"There's plenty out there if you know how to look for it," said Feinberg, who previously ran an online marketing and ad-tech firm based in New York. "These companies are playing whack-a-mole" in their fight against extremism, he said.